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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

RLS in Direct Query

Hi Guys

 

I created the below expression for RLS and it worked perfectly for my imported tables but when using the same for Direct Query it is giving me an error.

 

kindly help in sorting this as I'm stuck with this issue.

 

[CompanyId]=
CALCULATE (
MAX ( Deals[CompanyId] ),
FILTER ( Users, Users[LoginLevelName] = "Owner")
)

 

Error:

 

Himanshu_13_0-1609158484837.png

 

Regards,

Himanshu

6 REPLIES 6
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on my test,the RLS rule works in direct query:

My original table is as below:

Screenshot 2020-12-30 085650.png

And my RLS rule is :

Screenshot 2020-12-30 085726.png

And you will see that it works after clicking test as a role:

Screenshot 2020-12-30 085753.png

No error returns.

But if you are having an issue,you could try to separate the rule as below:

Screenshot 2020-12-30 085818.png

Then create a measure :

_Value = CALCULATE(MAX(TEST[Value]),FILTER(ALL(TEST),'TEST'[Country]=SELECTEDVALUE(TEST[Country])))

You will also see:

Screenshot 2020-12-30 085842.png

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

aj1973
Community Champion
Community Champion

Hi @Anonymous 

Direct Query mode comes with limitations, Including using measures

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-use-directquery

 

I recommend using the Power BI desktop feature to implement RLS

https://docs.microsoft.com/en-us/power-bi/admin/service-admin-rls

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

It doesnt solve the issue. 

 

Is there a way I can change this expression as per the Direct query?

 

[CompanyId]=
CALCULATE (
MAX ( Deals[CompanyId] ),
FILTER ( Users, Users[LoginLevelName] = "Owner")
)

 

Regards,

Himanshu

aj1973
Community Champion
Community Champion

Nothing wrong with the measure! but CALCULATE is not allowed in RLS

Did you try to implement RLS through the desktop instead of measure? if it didn't work then you might need to change the Mode of connection to Import mode at least for the User Table. But still you will need to use the RLS of the desktop.

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

amitchandak
Super User
Super User

@Anonymous , check ,if this video from guyinacube can help ?

https://guyinacube.com/2016/06/07/row-level-security-for-cloud-models-and-directquery-in-power-bi/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Amit,

 

Hope you're doing good.

 

This video doesn't help as I'm doing RLS at Desktop level and the video shows RLS functionality as Service level.

 

Regards,

Himanshu

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.