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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ShivaSDutta
Frequent Visitor

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

@ShivaSDutta , refer if this can help

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

@ShivaSDutta , refer if this can help

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.