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
abhiram342
Microsoft Employee
Microsoft Employee

RLS Dax Query

Hi Team,

 

I want to implement RLS on Product table and each user can see the sales for multiple products. I have created below DAX code and it's working fine . Want to check if there are other ways to rewrite same code (( in case if hits perf )

Example:

DAX Expression on Product Table

CALCULATE (
COUNTROWS ( 'Product' ),
FILTER (
VALUES ( 'Product'[Alias] ),
AND('Product'[Alias] = USERPRINCIPALNAME (),MAX('Product'[IsValidUser]) = TRUE())
)
) > 0

 

Relationships

1) ProducRLS (ProductID) * --> Product (ProductID)

2) Product(ProductID)<-- *Sales (ProductID)

 

defg@xyz.com --> will not see any data because they are not valid user

ProductRLS Table

ProductIDAliasIsValidUser
1abcd@xyz.comTRUE
2abcd@xyz.comTRUE
1defg@xyz.comFALSE

 

Product:

ProductIDName
1Pepsi
2Coco

 

Sales

DateIdProductIDSales
202305011100
202304011300
202305012200

Thanks,

Abhiram

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

Product[ProductID] IN CALCULTATETABLE(VALUES(ProductRLS[ProductID]),ProductRLS[Alias]=USERPRINCIPALNAME ()&&ProductRLS[IsValidUser]=TRUE())

View solution in original post

1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

Product[ProductID] IN CALCULTATETABLE(VALUES(ProductRLS[ProductID]),ProductRLS[Alias]=USERPRINCIPALNAME ()&&ProductRLS[IsValidUser]=TRUE())

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.