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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
charlottesmn
Frequent Visitor

Power BI RLS with list of IDs

Hello!

I have a use case where, for an embedded PowerBI report, I receive a list of IDs when calling the USERNAME() function (ie. id1,id2,id3,id4 for a user with 4 ids). A comma separates each ID.  

I had previously implemented a logic where PowerBI de-concatenates the ID and filters the table as needed. However, with more than 3 ids I am encountering performance issues and PowerBI times out.

Here is the code:

VAR currentuser = USERNAME ()
VAR isconcat = CONTAINSSTRING(currentuser, ",")

RETURN 
IF(isconcat,
CONTAINSSTRING("," & currentuser & ",", "," & [user_id] & ","),
[user_id] = currentuser)

 

I have also tried the following, which seems more performant but still not enough

VAR currentuser = USERNAME()
VAR UserIDs = SUBSTITUTE(currentuser, ",", "|")
RETURN
IF(
PATHCONTAINS(UserIDs, [user_id]),
TRUE(),
[user_id] = currentuser
)


Any idea on how I could solve this issue? 

Thank you

2 REPLIES 2
lbendlin
Super User
Super User

PATHCONTAINS is usually fast enough. How long is your list ?

 

In your example you are mixing boolean and text results. Probably not what you intended?

 

Your entire code should be more like

 

 

PATHCONTAINS(SUBSTITUTE(USERNAME(), ",", "|"), [user_id])

 

 

Thank you for the insight, I will try it now.

 

The biggest string I am getting is a list of 8 IDs, but my user table (where the RLS is applied) had almost 200,000 unique users. It is then related to my fact table with one-to-many relationships

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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