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
Aashishjain27
New Member

RLS with IF condition

Requirement is if following condition meets then only RLS should apply else RLS wont apply and user sees entire data.

following code not working id condition is meeting still user seeing entire data and RLS not applying. this all logic from single table which is filtering the data to fact and connected. workaround ? extratable ? Column ? 

 

= IF(
(
(CONTAINSSTRING([terr_id], "SCC") || CONTAINSSTRING([terr_id], "SNN"))
&& [terr_type] = "Territory"
),
LOWER(TRIM([emp_email])) = LOWER(TRIM(USERPRINCIPALNAME())),
TRUE()
)

3 REPLIES 3
lbendlin
Super User
Super User

Your condition translates into 

 

=
IF (
    ( CONTAINSSTRING ( [terr_id], "SCC" ) || CONTAINSSTRING ( [terr_id], "SNN" ) )
        && [terr_type] = "Territory"
        && LOWER ( TRIM ( [emp_email] ) ) <> LOWER ( TRIM ( USERPRINCIPALNAME () ) ),
    FALSE (),
    TRUE ()
)

 

This may not be what you intended.  You are also mixing static and dynamic RLS, which makes it even more complex.

Its dynamic only. following logic is working but the issue issue when the condition doesnt meet like [terr_id] <>"SCC", I want user to see entire data but with this logic user not seeing any data

IF (
    ( CONTAINSSTRING ( [terr_id], "SCC" ) || CONTAINSSTRING ( [terr_id], "SNN" ) )
        && [terr_type] = "Territory"
        && LOWER ( TRIM ( [emp_email] ) ) = LOWER ( TRIM ( USERPRINCIPALNAME () ) ),
    True (),
    FALSE()
)

That's not how dynamic RLS works. You are supposed to hold a permission mapping table that is keyed off the USERPRINCIPALNAME and then controls the rest of the data model.

 

You don't seem to have the required dimension tables for this?

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.