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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Filter by concatenated columns for RLS

Hi everyone

I have the following security table(sql) for my rls, I want to filter a table based on this 

UserPrincipalNameSite
usu1@example.coms1,s3,s6
usu2@example.coms2,s19,s23
usu3@example.coms3,s4

but, I couldn't filter by this Site column

and the next table is what i want to filter based on this security table

RegionCountrySite
Aas2
Abs1
Bcs19
Bds3
Ces4

 

 I think I was getting an error due I am using an IN operator but what my Site is returning me is kind of this "s1,s2,s3", so which will be the best option to do it?

 

Thank you in advance.

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

@Anonymous 

Your filter expression could be something like this (you will need to change the names of the tables to match your model).

 

VAR _UPN =
    USERPRINCIPALNAME ()
RETURN
    CONTAINSSTRING (
        LOOKUPVALUE ( Users[Site], Users[UserPrincipalName], _UPN ),
        Sites[Site]
    )

 

And you would apply that to the Sites table.

 

jdbuchanan71_1-1602172154584.png

jdbuchanan71_3-1602172190230.png

Although there is a weakness in doing it this way because PowerBI sees s2 in 's1,s23' so it is giving a false match.

If that is really how your site ID's are you may need to put in leading 0's  's02' instead of 's2' or you could split the sites in the users table then unpivot them to get 1 row per user/site pair.

 

 

 

 

View solution in original post

Anonymous
Not applicable

Hi @Anonymous 

When  we see the result as usu2@example.com,we should see S2,S19 and S23, however in 's reply we can see S1.

You may try my way, transform your User Table and build an RLS.

Splite Site column in rows in Power Query Editor.

Build a relationship between two site columns in two tables.

Try this Dax expression.

[Site] = 
CALCULATE (
    MAX(Data[Site]),
    FILTER (
        Users,
        Users[UserPrincipalName] = USERPRINCIPALNAME()
            && Users[Site] = Data[Site]
    )
)

 See the result as usu2@example.com.

Result:

1.png

You can download the pbix file from this link: Filter by concatenated columns for RLS

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

When  we see the result as usu2@example.com,we should see S2,S19 and S23, however in 's reply we can see S1.

You may try my way, transform your User Table and build an RLS.

Splite Site column in rows in Power Query Editor.

Build a relationship between two site columns in two tables.

Try this Dax expression.

[Site] = 
CALCULATE (
    MAX(Data[Site]),
    FILTER (
        Users,
        Users[UserPrincipalName] = USERPRINCIPALNAME()
            && Users[Site] = Data[Site]
    )
)

 See the result as usu2@example.com.

Result:

1.png

You can download the pbix file from this link: Filter by concatenated columns for RLS

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

jdbuchanan71
Super User
Super User

@Anonymous 

Your filter expression could be something like this (you will need to change the names of the tables to match your model).

 

VAR _UPN =
    USERPRINCIPALNAME ()
RETURN
    CONTAINSSTRING (
        LOOKUPVALUE ( Users[Site], Users[UserPrincipalName], _UPN ),
        Sites[Site]
    )

 

And you would apply that to the Sites table.

 

jdbuchanan71_1-1602172154584.png

jdbuchanan71_3-1602172190230.png

Although there is a weakness in doing it this way because PowerBI sees s2 in 's1,s23' so it is giving a false match.

If that is really how your site ID's are you may need to put in leading 0's  's02' instead of 's2' or you could split the sites in the users table then unpivot them to get 1 row per user/site pair.

 

 

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors