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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
alisaleh
Helper I
Helper I

UseRelationship() and RLS constrained

Hi All,

I'm stuck with the following error

The UseRelationship() and CrossFilter() functions may not be used when querying ‘TableA’ because it is constrained by row-level security defined on ‘TableA’ or related tables.

All I did is I created a measure on some table (TableX) that has inactive relationship (1:*) to TableA, since the relationship is inactive I used the the Userelationship function inside the calcuate. It worked for me but when I publish it other uses get the error above? I understand that both tableA and tableX have active relationship to the Project table which where the RLS filter is being applied. I need both relationship to exist to the project. How can I solve this?

Thanks for the help.

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@alisaleh you can also use the technique defined in this blog post Solving RLS Gotchas – Prologika

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

8 REPLIES 8
TatsianaS
Regular Visitor

Hi,

I've also encontared with such issue. It looks like you're trying to solve a problem when you need to apply RLS for table A at one page, but don't need that at another page. I've found a solution how to do it. 

Just create a meassure where you filter records in Table A according to your conditions and put it to Filter pane but don't put it to Filter pane at another page. Be sure your Filter pane is hidden for published report.

For example, you want to exclude the personal records of the current user from Table A: 

1. Personal Records = if(SELECTEDVALUE('Table A'[Email])=USERPRINCIPALNAME(),1,0)
2. Put to Filter pane "Personal Records" where value doesn't equal to 1
Contezini
Frequent Visitor

To whoever it might concern,

 

I had the same issue using USERELATIONSHIP() and RLS.

In my case,using INTERSECT() did not provide me with the correct results.

This is (a part) of my data Model:

Contezini_0-1697612046928.png

Basically, I need to achieve Sum of Hours tracked on Time Tracking Table per Workorder (unique IDs).

PS: TimeTracking can be done on different levels (not necessarily on a Workorder, thats why there's no active relationship)

My original DAX was as follows:

WO Hours =
CALCULATE(
    SUM('Time Tracking'[Quantity]),
    USERELATIONSHIP(
        Workorders[WO],
        'Time Tracking'[Workorder_No]
    )
)

So I have changed it to the following calculation, where it worked just fine:

WO Hours =
VAR xWO = SELECTEDVALUE(Workorders[WO],FALSE())
RETURN
IF( xWO=FALSE,
    SUM('Time Tracking'[Quantity]),
    CALCULATE(
        SUM('Time Tracking'[Quantity]),
        'Time Tracking'[Workorder_No] = xWO
    )
)

Thought the measure requires much more capacity (takes longer to load), now the model is working just fine 🙂

parry2k
Super User
Super User

@alisaleh exactly, glad you have a solution. Cheers!!

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@alisaleh you can also use the technique defined in this blog post Solving RLS Gotchas – Prologika

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k ,

I saw that post, and I did not understand how you can use the intersect in the place of userelationship. The userelationship is function used in Calculate. can you provide an example ?

It turns out you can use intersect in calculate function semilar to USERELATIONSHIP()

alisaleh
Helper I
Helper I

hi @Jeanxyz ,

 

Thanks for your reply. I will check the video and see if it will help. as I mentioned in my first post there is project table that both A and X are connected to and that project table is the one has the RLS. Its not that straight forward but just to simplify it because the project table is connected indirectly through other dimension table which is connected to table A and I need this relation ship to stay.

Jeanxyz
Post Prodigy
Post Prodigy

Can you check which dimension table is used to set up RLS? If table A is used to set up RLS filter (as the erro message suggests), that would indeed be risky. 

As an alternative solution, maybe you can create RLS using lookupvalue, to avoid creating any relationship. That might solve the issue.

 

https://www.youtube.com/watch?v=9wN33rTaiB4&t=498s

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors