Forum Discussion

JustinDoh1's avatar
JustinDoh1
Post Prodigy
1 year ago
Solved

Need help with DAX expression on RLS

I have attached PBIX file here.   I am trying to modify the bottom DAX so that it meets the condition of AccessToAllLocations = 'Yes' as I intended.   Bottom is current DAX that I have for RLS: ...
  • v-pnaroju-msft's avatar
    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.

    1. 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.