Forum Discussion
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.
alisaleh you can also use the technique defined in this blog post Solving RLS Gotchas – Prologika
✨ Follow us on LinkedIn and 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.
8 Replies
- parry2k
Super User
alisaleh you can also use the technique defined in this blog post Solving RLS Gotchas – Prologika
✨ Follow us on LinkedIn and 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.
- alisaleh
Advocate I
It turns out you can use intersect in calculate function semilar to USERELATIONSHIP()
- Jeanxyz
Power Participant
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.
- alisaleh
Advocate 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.
- parry2k
Super User
alisaleh exactly, glad you have a solution. Cheers!!
✨ Follow us on LinkedIn and 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.
- ConteziniFrequent 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:
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 🙂
- TatsianaSRegular 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