Row filtering based on condition not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2025 05:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 07:32 AM
Hey @HeathDG1
I think your function isn’t behaving the way you expect because of how the logic is set up:
•If the user is in Stern MA, they only see rows where state = 'MA' (which is good).
•BUT for everyone else, the function returns true, meaning they see all the data
To properly restrict access for users outside Stern MA, you need to return false by default instead of true:
CREATE OR REPLACE FUNCTION dream_team.stern_portfolio.state_filter(state STRING)
RETURNS BOOLEAN
RETURN
IF(IS_ACCOUNT_GROUP_MEMBER('Stern MA'), state = 'MA', false);
• If the user is in Stern MA → They get state = 'MA' (so they only see data for MA).
•If the user is NOT in Stern MA → The function returns false, meaning they see nothing at all.
Once the function is corrected, apply the row filter to your table
To various groups:
CREATE OR REPLACE FUNCTION dream_team.stern_portfolio.state_filter(state STRING)
RETURNS BOOLEAN
RETURN
CASE
WHEN IS_ACCOUNT_GROUP_MEMBER('Stern MA') THEN state = 'MA'
WHEN IS_ACCOUNT_GROUP_MEMBER('Stern NY') THEN state = 'NY'
WHEN IS_ACCOUNT_GROUP_MEMBER('Stern CA') THEN state = 'CA'
ELSE false
END;
Hope this helps 🙂

