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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Help with RLS for inactive relationships with USERELATIONSHIP

Hi!
We would like to use RLS on seller in this testexample with USERPRINCIPALNAME().
The dimension has multiple relationships to the fact table workorders. 

tobiasnygren_1-1711621304650.png

 

And from the documentation we will get some challenges with RLS and USERELATIONSHIP.

https://learn.microsoft.com/en-us/dax/userelationship-function-dax

 

USERELATIONSHIP cannot be used when row level security is defined for the table in which the measure is included. For example, CALCULATE(SUM([SalesAmount]), USERELATIONSHIP(FactInternetSales[CustomerKey], DimCustomer[CustomerKey])) will return an error if row level security is defined for DimCustomer.

 

What options do we have?
- I think it will work if I unpivot the columns so I only get one active relationships, but in that case I will dupplicate a lot of data.

tobiasnygren_0-1711621592248.png


How do you solve cases like this with RLS and USERELATIONSHIP?
Do you have a better solutions to solve this without unpivot?

 

Example files
https://drive.google.com/drive/folders/1f-0nr36SaxNqTxP1Qyq585p3fhcdt4bx?usp=drive_link

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I think I have found the solution in this articel from SQLBI
"DAX limitations with inactive relationships and row-level security (RLS)"
https://www.sqlbi.com/articles/dax-limitations-with-inactive-relationships-and-row-level-security-rl...

View solution in original post

5 REPLIES 5
Villezekeviking
Most Valuable Professional
Most Valuable Professional

I wrote a solution here where you modify the model and no longer need multiple relationships.  

https://www.villezekeviking.com/alternative-to-userelationship/

Anonymous
Not applicable

Hi @Anonymous ,

 

Thanks for your feedback.

 

Best Regards,
Adamk Kong

Anonymous
Not applicable

I think I have found the solution in this articel from SQLBI
"DAX limitations with inactive relationships and row-level security (RLS)"
https://www.sqlbi.com/articles/dax-limitations-with-inactive-relationships-and-row-level-security-rl...

Anonymous
Not applicable

Hi @Anonymous ,

 

You can  modify your formula like below:

vkongfanfmsft_1-1711698916457.png

# of rows with inactive repationship = 
CALCULATE
(
  COUNTROWS(Orders)
  , USERELATIONSHIP(Seller[Id],Orders[Seller_col2])
)

 

But note: USERELATIONSHIP cannot be used when defining row-level security for tables containing measure.

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Anonymous
Not applicable

The challenge is that we need to use row-level security for this.

tobiasnygren_0-1712047471493.png

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors