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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How do i create a RLS role for 2 scenarios

I have a cost code column and a Email ID column. User should get the access of cost code against the email ID and in case of * against the email id user to should have access to all the cost code.

 

CostcodeEmail-ID
12365abc@outlook.com
87907bcd@outlook.com
26543abc@outlook.com
*bgy@outlook.com
283920bcd@outlook.com

 

bgy@outlook.com should have access to all the cost code.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , refer if this can help

Power BI- Row Level Security: Handle ALL, UserPrincipalName: https://youtu.be/KVLEnIUo4pc

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

I am assuming you are filtering another table that has data by cost code.  You would apply a filter to that table by reading from the UserAccess table like this.

VAR _UPN = USERPRINCIPALNAME()
RETURN
    IF (
        LOOKUPVALUE (
            UserAccess[Costcode],
            UserAccess[Email-ID], _UPN,
            UserAccess[Costcode], "*"
        ) = "*",
        TRUE,
        'Table'[CostCode]
            = LOOKUPVALUE (
                UserAccess[Costcode],
                UserAccess[Email-ID], _UPN,
                UserAccess[Costcode], 'Table'[CostCode]
            )
    )

I have attached my sample file for you to look at.  You can test the RLS by using View As on the modeling ribon

You can see that bgy can see all rows:

jdbuchanan71_1-1680711687925.png

but bcd can only see the subset he is assigned to

jdbuchanan71_0-1680711672138.png

 

 

 

amitchandak
Super User
Super User

@Anonymous , refer if this can help

Power BI- Row Level Security: Handle ALL, UserPrincipalName: https://youtu.be/KVLEnIUo4pc

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.