Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX Code for Dynamic RLS

I am new to DAX and am trying to implement some dynamic RLS. The current table of users details looks like below:

User EmailUser NameAgent IDLevel of Access RequiredRegionCompany
test@xxx.comTest123123IndividualUSACompany1
test@xxx.comTest456456RegionalUKCompany2
test@xxx.comTest789789NationalAUSCompany3

 

What I want to do is give a user access at a level defined in 'Level of Access Required'.

This has 3 options:

1) National which will show all data for the specific company

2) Regional which will show all data for the specific company and the region

3) Individual which will show all data for user with the Agent ID

 

This table mentioned above will then be joined on to the other datasets within the report using a many to many join relationship I imagine?

 

Let me know if any further information is required.

1 ACCEPTED SOLUTION

sorry, was a bit quick there, you need to write it like this

VAR _t =
    CALCULATETABLE (
        VALUES ( 'Access_Table'[Access_Required] ),
        FILTER ( 'Access_Table', 'Access_Table'[User_Email] = USERPRINCIPALNAME () )
    )
RETURN
    IF (
        CONTAINS ( _t, 'Access Table'[Access_Required], "National" )
            || CONTAINS ( _t, 'Access Table'[Access_Required], "Regional" ),
        'dimCompany'[Company]
            IN CALCULATETABLE (
                VALUES ( 'Access_Table'[Company] ),
                FILTER ( 'Access_Table', 'Access_Table'[User_Email] = USERPRINCIPALNAME () )
            ),
        TRUE ()
    )

View solution in original post

18 REPLIES 18

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.