Forum Discussion
Need help with DAX expression on RLS
- 1 year ago
Hi JustinDoh1,
Based on my understanding, the Security Cross Filtering error arises due to the Apply security filter in both directions setting. Kindly uncheck this option in the relationship between tblPBIGroup and tblPBISecurity, and set the direction to Single from tblPBIGroup to tblPBISecurity. Then, reapply the DAX expression to tblPBISecurity. This should help resolve the issue.
-
For handling multiple locations, please use the updated DAX expression below:
VAR _User = USERPRINCIPALNAME()VAR _AccessToAll = MAXX(FILTER('tblPBIGroup', 'tblPBIGroup'[User] = _User), 'tblPBIGroup'[AccessToAllLocations])
VAR _UserLocations = FILTER('tblPBIGroup', 'tblPBIGroup'[User] = _User)
RETURN
IF(
_AccessToAll = "Yes",
TRUE(),
'tblPBISecurity'[Group] IN SELECTCOLUMNS(_UserLocations, "Location", 'tblPBIGroup'[Location])
)
This logic allows users to access multiple locations as listed in the tblPBIGroup table.
2.The TRUE() function grants unrestricted access to all rows in tblPBISecurity when AccessToAllLocations is set to Yes. Otherwise, it restricts access based on the specific locations.If you find this response helpful, kindly mark it as the accepted solution and consider giving kudos. This will be beneficial for other community members facing similar queries.
Thank you.
-
Hi JustinDoh1,
Thank you for reaching out to the Microsoft Fabric Community Forum.
Please find the revised DAX expression to be applied to the tblPBISecurity table for Row-Level Security (RLS). Kindly check if it resolves the issue:
VAR _User = USERPRINCIPALNAME()
VAR _AccessToAll = MAXX(
FILTER( 'tblPBIGroup', 'tblPBIGroup'[User] = _User ),
'tblPBIGroup'[AccessToAllLocations]
)
VAR _UserLocation = MAXX(
FILTER( 'tblPBIGroup', 'tblPBIGroup'[User] = _User ),
'tblPBIGroup'[Location]
)
RETURN
IF(
_AccessToAll = "Yes",
TRUE(),
'tblPBISecurity'[Group] = _UserLocation
)
If you find our response helpful, we kindly request you to mark it as the accepted solution and provide kudos. This will assist other community members who may have similar queries.
Thank you.
- JustinDoh11 year agoPost Prodigy
Thank you so much for your help.
I am having an error recognizing a table value ('tblPBISecurity'[Group]) because, I think, the DAX is currently pointing to tblPBIGroup on the expression Window on the right side.
How do we fix this issue?
Thanks.