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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sundeep579
Frequent Visitor

Not able to use string DAX functions in RLS filter criteria with DirectQuery

I have a scenario wherein I need to do apply SQL LIKE '%USERNAME()%' filter in Table filter DAX expression to setup Row level security to work with a SQL server setup using DirectQuery. I tried to use FIND(), SEARCH(), LOOKUPVALUE() DAX functions in Table filter DAX expression box, but I keep getting an error sayng 'Function SEARCH is not allowed as part of the row level security expression on DirectQuery models'. Is there any workaround to this ?

 

All I need is to setup a [MyColumnName] LIKE '%USERNAME()%' filter in Table filter DAX expression. Is there anyway to set this up in Power BI ?

4 REPLIES 4
bblais
Resolver III
Resolver III

I was able to make it work with SEARCH using the following.  This is searching my Geography[City] column for any city with "ville" in it.

 

IFERROR(IF(SEARCH("*VILLE*",Geography[City])>0,TRUE(),FALSE()),FALSE())

 Hopefully you can adapt it to your scenario...

My apologies, this is not on a DirectQuery model so it may not work, as you suggested already. I will attempt to solve it for a DirectQuery model as well.

Yes, I am getting this error only while using DirectQuery whereas in Import mode everything is working fine.

It looks like it is not currently possible to do the "LIKE" search within SQL DirectQuery RLS, as you have indicated.  Perhaps you can piece together a string that would be an exact match so you don't have to use LIKE?  I haven't seen your data, but if your database has only username in it but you are getting DOMAIN\username from the call to the USERNAME() DAX function, you could parse out the domain name and slash so then it would be exact match...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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