March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi!
I have a main datasource which contains data about worklogs, grouped by month/year/project and employee, with these fields:
- Employee
- Project
- Month
- Year
- Time in hours
- Employee division
- Project Division
And one RLS tables with these fields:
- division (which can be either employee division or project division)
- User (email address)
The role that i created is based on the rule that User = USERPRINCIPALNAME()
How could I simulate an or condition so that for a specific user data could be displayed either when employee division = division from RLS or project division = division from RLS?
The relation between tables is many to many, a user can be assigned to multiple divisions.
Solved! Go to Solution.
Hi,
You can apply RLS to the main table (WorkLogs) instead of the RLS table and check like this:
= CONTAINS('RLSTable', 'RLSTable'[User], USERPRINCIPALNAME(), 'RLSTable'[division], 'WorkLogs'[Employee division])
|| CONTAINS('RLSTable', 'RLSTable'[User], USERPRINCIPALNAME(), 'RLSTable'[division], 'WorkLogs'[Project division])
You don't need any relations between the two tables. Caching of RLS will stop working if you have more than about 130 000 rows, but if the table is not too big it will probably work even if you exceed that number.
If performance is not good enough with the above solution, my suggestion is to add some kind of bridge table between the WorkLogs table and RLStable that connects worklog rows with rows in the RLS table.
Best Regards // Ulf
Hi,
You can apply RLS to the main table (WorkLogs) instead of the RLS table and check like this:
= CONTAINS('RLSTable', 'RLSTable'[User], USERPRINCIPALNAME(), 'RLSTable'[division], 'WorkLogs'[Employee division])
|| CONTAINS('RLSTable', 'RLSTable'[User], USERPRINCIPALNAME(), 'RLSTable'[division], 'WorkLogs'[Project division])
You don't need any relations between the two tables. Caching of RLS will stop working if you have more than about 130 000 rows, but if the table is not too big it will probably work even if you exceed that number.
If performance is not good enough with the above solution, my suggestion is to add some kind of bridge table between the WorkLogs table and RLStable that connects worklog rows with rows in the RLS table.
Best Regards // Ulf
I think because of the relation (many to many) it gives me an error: A single value value for column Employee division cannot be determined. This can happen when a measure refers to column that contains many values without specifying an aggregation.
Hi @IoanaSluby
how to do this will depend on your data and the desired output. Could you provide some relevant sample data and a mockup of your desired output?
Cheers,
Sturla
Currently, there is a relation between the RLS table and Project Division (RLS filtering Main datasource) and a role which says that User = USERPRINCIPALNAME().
What i would like to achieve is displaying for User = user1@gmail.com, since he has rights on Commerce division, both the rows where Employee Division = Commerce or where Project Division = Commerce.
@IoanaSlubyDid you get the error message when you tried the DAX I posted earlier? It should be on the main data source table, not on the RLS table. And you should remove the relationship.
RLS expression on Main Data source table:
= CONTAINS('RLS Table', 'RLS Table'[User], USERPRINCIPALNAME(), 'RLS Table'[Division], 'Main Data source'[Employee division])
|| CONTAINS('RLS Table', 'RLS Table'[User], USERPRINCIPALNAME(), 'RLS Table'[Division], 'Main Data source'[Project division])
Best Regards // Ulf
I have exactly the same issue, and I'm not an expert on Power Bi. Would you please give me specific instructions on where would I put the above expression?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
21 | |
16 | |
14 |