Forum Discussion
Data level security on Power BI
I actually tried creating roles with table[username]= USERNAME( )
But not sure how to assign the PM Code for the logged in user to the actualy Project table which has PM Info.
You don't do anything with the PM code. Presumably you have a relationship between this user table and your regular data, and you normally use it to filter and categorize that data. I don't know your specific case but for example imagine that your user table is a table of sales reps where each username is accompanied by a matching email address column, and linked to that table you have a table of sales data. You show sales results by sales rep in your report. If you create a "sales rep" security role with a filter on the user table of usertable[email address] = USERNAME(), then publish that report and add each of the sales rep users to that security role on the service, when they look at the report it will show only their individual sales results and nobody else's.
- akj27848 years agoPost Partisan
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.
- Tadder8 years agoHelper II
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()
)
- Anonymous8 years agoNot applicable
Well that's not really how row level security works. You're going to have to come up with some way for the Power BI service to recognize the user's PM code by their Microsoft user account. The only way to do that is to use that user account as an identifier. The account is the email address.