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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
WarrenStaples
Frequent Visitor

Help with DAX expression in RLS

Hi, 

 

New to powerbi and I was wondering if someone could help with a DAX expression. I have a users table with UserID, Username and a column called FinanceAccess. The FinanceAccess column has values, Y and N. Anyone with Y can access the report and people with N should not have access. 

 

I'm unsure how to write the DAX here. I've written the following but I get an error message. Thanks for the help. 🙂

[Username] IN
SELECTCOLUMNS (
            FILTER (
             'Users_', 
             'Users_[FinanceAccess])
                = "Y" 
             ),
            "Username", [Username]
)

 

1 ACCEPTED SOLUTION

Hey @WarrenStaples ,

 

the problem is the filter direction in the data model.

Check the following criteria for the sales table:

 

[NetworkID] in 
SELECTCOLUMNS (
    FILTER (
        Network,
        RELATED ( Users[Username] ) = USERPRINCIPALNAME () && RELATED(Users[FinanceAccess]) = "Y"
    ),
    "NetworkID", Network[NetworkID]
)

 

 

15.png

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi Mate,

 

You can try the following expression: 

 

M_RLS = CALCULATE(VALUES('Table'[Country]),FILTER('Table','Table'[Person]="Y" && 'Table'[Country]=SELECTEDVALUE(Sheet1[Country])))
 
VishalGupta374_0-1616605871173.png

This table is mapping table and its connected to main table with 1:Many relationship.

 

I received expected output.

 

VishalGupta374_1-1616606016478.png

 

selimovd
Super User
Super User

Hey @WarrenStaples ,

 

where do you want to use that?

Is that the criteria for a role?

 

Is username the e-mail address? Then you could use USERNAME() or USERPRINCIPLENAME() to check against the table.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

@selimovd Yes, I would like to use Username() to check against the table and use in the manage roles section. Basically anyone with FinanceAccess marked as Y should have access to the report. 

 

Capture789.JPG

Hey @WarrenStaples ,

 

then use the following DAX code for the row level security:

Users_[Username] = USERNAME() && Users_[FinanceAccess] = "Y"

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

@selimovd Thank you. It doesn't however seem to have any effect on the data. So with flag Y, users should see all data in Sales Table, with Flag N they shouldn't see anything. 

I've included my file here: File 

Hey @WarrenStaples ,

 

the problem is the filter direction in the data model.

Check the following criteria for the sales table:

 

[NetworkID] in 
SELECTCOLUMNS (
    FILTER (
        Network,
        RELATED ( Users[Username] ) = USERPRINCIPALNAME () && RELATED(Users[FinanceAccess]) = "Y"
    ),
    "NetworkID", Network[NetworkID]
)

 

 

15.png

 

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

@selimovd Thanks Denis. And what do you have in the Roles in the User table?  I have the following below but for example, Sam in the table doesn't see anything although he has a Y flag. Perhaps you could attach the file you worked on above? Thanks again.

 

Capture4566456465.JPG

Hey @WarrenStaples ,

 

Sam has UserID 8:

1.png

 

He doesn't see anything because in the related table he doesn't have any data or network connected:

2.png

 

From your first description you wanted 2 criteria:

1. The users see the data they have access to. Sam doesn't, so he won't see anything

2. If the user has a "Y" on Finance Access he is in addition allowed to see the financial data from table Sales.

 

Please let me know if I understood anything wrong.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi Denis, You're right. Thank you. 

Hey @WarrenStaples ,

 

no problem. I'm happy it worked eventually 🙂

If you need further help just let me know.

 
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.