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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic RLS with 2 columns

Hi all,

I am trying to create a dynamic RLS.

Cretiria: 

RLS - code = "All", can view all data

RLS - code = "HK_store1" can only view HK_store1's data

RLS - code = "HK" can view all stores' data from HK (store1 & store2.....)

RLS:

NameEmail Addresscode
userAA@test.comAll
userBB@test.comHK_store1
userCC@test.comHK_store2
userDD@test.comTW_store1
userEE@test.comHK

 

RLS - [code] --> Fact Table - [Store Code]: Security Filter in both direction

Fact Table:

Store CodeMkt Code
TW_store1TW
HK_store1HK
HK_store2HK
AllAll
HKHK

 

I am currently using this code for RLS control, could you please advise how I could write the logic for

if RLS - code = "HK" then Fact Table - Mkt code ="HK

 

 

 

 

VAR _Role = MAXX(FILTER( RLS, RLS[Email Address] = USERNAME() ), RLS[code])
RETURN
if (_Role = "All", TRUE(),
[Email Address] = USERNAME() )

 

 

 

  

alexng_0-1644932910527.png

Great thanks if any suggestions.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , One of the option such case to have table like

 

Store All Store
HK HK
HK_store2 HK_store2
TW_store1 TW_store1
HK_store2 All
TW_store1 All
HK All

 

Merge this with RLS table using code and all store , then you will get column with store that you can join with fact and filter on it

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , One of the option such case to have table like

 

Store All Store
HK HK
HK_store2 HK_store2
TW_store1 TW_store1
HK_store2 All
TW_store1 All
HK All

 

Merge this with RLS table using code and all store , then you will get column with store that you can join with fact and filter on it

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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