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
nsj2113
Frequent Visitor

USERNAME() function DAX

Hi,

 

I am trying to use Row Level Security for my Power Bi model and for that I am using username() function to get the filters. The thing is that I have two filters to pass and thus would like my username() function to be able to take 2 values. Is there any way of doing it ?

1 ACCEPTED SOLUTION
chrisu
Responsive Resident
Responsive Resident

Not quite sure if this is what you're looking for, but I do something similar using LOOKUPVALUE.  Basically I find where USERNAME() matches the Email in the Users table and then filter the Programs table where either the returned Program 1 or Program 2 match.  The filters on the Programs table then flow to all the other tables in my model.  

 

Programs

Program

 

Users

User 1     Email     Program 1     Program 2

 

My RLS set up in the Programs table is: 

 

[Program] = LOOKUPVALUE(Users[Program 1], [Email], USERNAME()) || [Program] = LOOKUPVALUE(Users[Program 2], [Email], USERNAME())

View solution in original post

4 REPLIES 4
chrisu
Responsive Resident
Responsive Resident

Not quite sure if this is what you're looking for, but I do something similar using LOOKUPVALUE.  Basically I find where USERNAME() matches the Email in the Users table and then filter the Programs table where either the returned Program 1 or Program 2 match.  The filters on the Programs table then flow to all the other tables in my model.  

 

Programs

Program

 

Users

User 1     Email     Program 1     Program 2

 

My RLS set up in the Programs table is: 

 

[Program] = LOOKUPVALUE(Users[Program 1], [Email], USERNAME()) || [Program] = LOOKUPVALUE(Users[Program 2], [Email], USERNAME())

bises
Frequent Visitor

This solution works perfectly but I was confused on the second part "The filters on the Programs table then flow to all the other tables in my model"

 

I am trying to filter other tables with no user info in them but has relation to programs. And I try to filter other table based on the programs table I am not able to filter that. 

bises
Frequent Visitor

This solution works perfectly but I was confused on the second part "The filters on the Programs table then flow to all the other tables in my model"

 

I am trying to filter other tables with no user info in them but has relation to programs. And I try to filter other table based on the programs table I am not able to filter that. 

Thanks that worked perfectly. 

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.

Top Solution Authors