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

With Users table and RLS, data is limited if no user is associated to another table

StateCode joins these tables:

AlanJacobson_0-1693490458397.png

 

 

I ONLY have users for 2 states, MN and TX:

AlanJacobson_3-1693490583206.png

 

Even though there's a few states:

AlanJacobson_4-1693490622910.png

And a few cities joined to states:

AlanJacobson_5-1693490650650.png

 

 

 

Users are related to states with security:

AlanJacobson_1-1693490495833.png

 

Users can have a Role of "ViewAll" or "Limited". Dax formula allows "ViewAll" to see all data:

 

AlanJacobson_2-1693490550091.png

 

So when I view as limited user I only see the one state:

 

AlanJacobson_6-1693490743262.png

 

 

BUT when I view as ViewAll role, I don't see every state. I only see states that have a record in the Users table. Because no user is associated to Wisconsin, I cannot see the WI cities:

AlanJacobson_7-1693490783634.png

 

 

So the absence of "WI" in the Users table prevents a "ViewAll" user from seeing those Wisconsin cities. How can I structure this so all cities appear for ViewAll?

 

Geoff

1 ACCEPTED SOLUTION
AlanJacobson
Frequent Visitor

I solved by removing security from the Users -> States relationship and applying a Role dax filter only to the States table directly. In that expression I can check for role and state for the current user, then apply those values.

 

 

// get the current state code
VAR _stateCode =
MAXX(
      FILTER( 'Users', 'Users'[EmailAddress] = USERPRINCIPALNAME() )
, 'Users'[StateCode])

// current role
VAR _roleCode =
MAXX(
      FILTER( 'Users', 'Users'[EmailAddress] = USERPRINCIPALNAME() )
, 'Users'[Role])

// if ViewAll, the user can see all the data, otherwise limit data based on logged in email address -> state code
RETURN
IF(
_roleCode = "ViewAll", TRUE(),
[StateCode] = _stateCode )

 

View solution in original post

1 REPLY 1
AlanJacobson
Frequent Visitor

I solved by removing security from the Users -> States relationship and applying a Role dax filter only to the States table directly. In that expression I can check for role and state for the current user, then apply those values.

 

 

// get the current state code
VAR _stateCode =
MAXX(
      FILTER( 'Users', 'Users'[EmailAddress] = USERPRINCIPALNAME() )
, 'Users'[StateCode])

// current role
VAR _roleCode =
MAXX(
      FILTER( 'Users', 'Users'[EmailAddress] = USERPRINCIPALNAME() )
, 'Users'[Role])

// if ViewAll, the user can see all the data, otherwise limit data based on logged in email address -> state code
RETURN
IF(
_roleCode = "ViewAll", TRUE(),
[StateCode] = _stateCode )

 

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.