Forum Discussion
Data level security on Power BI
ok. I see your point but that's not exactly what I want to implement.
Thank you for your guidance.
In my actual project table I don't have user name/email. All I have is PM Code. I have to drive the dashboard based on that and apply the data level security so that each PM can see only his Projects in the dashboard.
You need to add a column to your users table for their Office365 email account. Then do a lookup in the row level security based on that. USERPRINCIPALNAME() returns the current users login (email address). So the filter is on PM_CODE. LOOKUPVALUE() is looking for the PM_CODE of the USERPRINCIPALNAME and uses the EMAIL_ADDRESS as a cross reference. The result of this is filtering for PM_CODE = AKASH or whoever the logged in user is.
It would look like this:
- akj27848 years agoPost Partisan
That did not work. Let me elaborate the scenario.
I have two tables Project and Security. Project is a dimension table which is joined to many fact tables to get the revenue, forecast etc.
And Security tables holds who can see what. So Akash can see only Projects for PmCode=1234, similarly Ajay can see only Projects where PMCode=3234
I tried to add the following on the PMCode of Security table, but it is not restricting the data correctly.
[PMCode] = LOOKUPVALUE(
[PMCode],
[UserName], USERPRINCIPALNAME()
) - Tadder8 years agoHelper II
I'm noticed there are spaces in the Headers for the Security table, and no spaces in the LOOKUPVALUE function (PM CODE vs PMCODE). Problably not the issue, but better safe than sorry, so check that out.
Add a new measure in PBI Desktop for LoggedInAs = USERPRINCIPALNAME(). Add a card to your report (temporarily) to show who is logged in. Switch to View As a different user. Does LoggedInAs show what you expect? It should show AKASH's email address if done properly.
Actually - Now that I've read a little closer - you're using the wrong User field in the lookup. Use UserID instead of UserName. You want to look up the EMAIL and return the PMCODE. Should not use USERNAME at all. :) But showing who the logged in user is on the report is pretty cool too. I use it.