Forum Discussion
Row level security _ DAX
Hi Anonymous
Your screenshot does not show all the fields of the various tables, and I can't see which fields are used to create the relationships, so this is a bit of guess work. Could you add this to the V_SECU_SECTOR-table
RegionID in
CALCULATETABLE (
VALUES ( V_SECU_REGION[RegionID] ),
FILTER ( V_SECU_REGION; V_SECU_REGION[User_ID] = USERPRINCIPALNAME () )
)
You can also use this together with other conditions, just use || between the statements
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Hello sturlaws
Here is a more clear screenshot I actually don't have the regionID in my TD_SECU_SECTOR table however, however, I have added your code to my V_SECU_REGION2 table and it doesn't give me the results I need.
Let's say I have 2 users and 2 regions, each composed of 3 sectors, then my tables would look like this:
V_SECU_REGION2 TD_SECU_SECTOR
index user regionID index user sectorID
1 user 1 regionA 1 user2 sectorB1
2 user2 regionB 2 user2 sectorB3
It means that my user1 is supposed to see all sectors of regionA, here is more screenshot to explain my current situation
I was thinking about using an IF statement to apply security that behaves in this way:
IF ( user from V_SECU_REGION2 exists in TD_SECU_SECTOR
THEN get sectorID from TD_SECU_SECTOR which will filter my TD_SECTOR which will filter my fact table
ELSE get sectorID directly from TD_SECTOR which will filter my fact table [can't get the code to work correctly] )
I thought of using this code when I have a case like user1 but it doesn't work:
- sturlaws6 years agoResident Rockstar
Hmm,
you have 2 relationship which might be a bit troublesome:
1. The inactive many-to-many-relationship between TD_SECU_SECTOR and V_SECU_REGION2. Many-to-many is a potential minefield in PBI.
2. The bidirectional relationship between TD_REGION and V_SECU_REGION2.
I have created a simple demo report to show how I would have solved it:
- Anonymous6 years agoNot applicable
Hi sturlaws
Thank you for the advices and your time. I tired to avoid the bidirectional relationship, but in this context, I needed one.
I also tried to implement your solution, but it didn't work (when I test it with username = "test")
I also didn't understand the logic behind it and I think my schema is a bit more complicated than the sample file you provided me. I work with a galaxy schema.
I have made a sample file more specific to my context
Thanks in advance for the help,
Mariem,
- sturlaws6 years agoResident Rockstar
I made some modifications to your file:
sampleFileSecu.pbix