Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
| ProductID | Alias | IsValidUser |
| 1 | abcd@xyz.com | TRUE |
| 2 | abcd@xyz.com | TRUE |
| 1 | defg@xyz.com | FALSE |
Product:
| ProductID | Name |
| 1 | Pepsi |
| 2 | Coco |
Sales
| DateId | ProductID | Sales |
| 20230501 | 1 | 100 |
| 20230401 | 1 | 300 |
| 20230501 | 2 | 200 |
Thanks,
Abhiram
Solved! Go to Solution.
Product[ProductID] IN CALCULTATETABLE(VALUES(ProductRLS[ProductID]),ProductRLS[Alias]=USERPRINCIPALNAME ()&&ProductRLS[IsValidUser]=TRUE())
Product[ProductID] IN CALCULTATETABLE(VALUES(ProductRLS[ProductID]),ProductRLS[Alias]=USERPRINCIPALNAME ()&&ProductRLS[IsValidUser]=TRUE())
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 13 | |
| 12 | |
| 9 | |
| 8 | |
| 7 |