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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dancarr22
Helper V
Helper V

Applying Row Level Security using LIKE

Hello,

 

We have RLS (row level security) set up on our data model and it is working properly.

But, we have a new request which I need assistance with: how do you set up RLS for a table where we are filtering using LIKE.  i.e. Only display where field DeptID STARTSWITH 'HR%'.  There is no 'begins with' option and if I go into the DAX editor it does not recognize STARTSWITH.  Accessing this from Modeling -> Manage Roles.

STARTSWITH([DeptID], "HR") not recognized/does not work.

Apprecate any assistance you can provide.

 

Thanks,

Dan

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @dancarr22 ,

Thanks for reaching out. You're correct that the STARTSWITH function isn't supported directly in the DAX expression editor within the "Manage Roles" interface for Row-Level Security. However, you can achieve the same functionality using the LEFT function or the SEARCH function in combination with a logical comparison.

 

For your use case, a simple workaround would be to use an expression like LEFT([DeptID], 2) = "HR", which effectively mimics the STARTSWITH behavior. Alternatively, you can use SEARCH("HR", [DeptID], 1, 0) = 1, which checks if "HR" appears at the beginning of the DeptID field. Either of these approaches should allow you to implement the desired RLS rule based on prefix filtering. Let me know if you need help applying this in your specific model.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

4 REPLIES 4
dancarr22
Helper V
Helper V

Thanks all - @rohit1991  @danextian  and @lbendlin for your help.  Worked as you mentioned - and did see a bit of a performance hit.

rohit1991
Super User
Super User

Hi @dancarr22 ,

Thanks for reaching out. You're correct that the STARTSWITH function isn't supported directly in the DAX expression editor within the "Manage Roles" interface for Row-Level Security. However, you can achieve the same functionality using the LEFT function or the SEARCH function in combination with a logical comparison.

 

For your use case, a simple workaround would be to use an expression like LEFT([DeptID], 2) = "HR", which effectively mimics the STARTSWITH behavior. Alternatively, you can use SEARCH("HR", [DeptID], 1, 0) = 1, which checks if "HR" appears at the beginning of the DeptID field. Either of these approaches should allow you to implement the desired RLS rule based on prefix filtering. Let me know if you need help applying this in your specific model.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
danextian
Super User
Super User

You can do LEFT([column], 2) = "HR".





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
lbendlin
Super User
Super User

You can use FIND or SEARCH for that and validate if the search term is at position 1.

 

Be prepared for a massive performance impact though.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.