Forum Discussion
Filter out using USERPRINCIPALNAME()
Hello all,
Please see the below data. When i publish the below view in the service if i login with "[email protected]" i dont want to see 1st record and If an user login with "[email protected]" we dont need 2nd record.
| Name | Scores | |
| Harsha | [email protected] | 1 |
| Gururaj | [email protected] | 2 |
| King | [email protected] | 3 |
I tried creating a column as
If(email=USERPRINCIPALNAME(),1,0)
But since i connected my dashboard as directquery i get an error.
Please help me to filter out the data.
You can create an RLS role with the rule
[email] <> USERPRINCIPALNAME()Once you have created a role, anyone you want to view the report must be assigned to a role. This is the intended functionality and there isn't a way to avoid assigning roles if you want to use RLS.
See the documentation and prior discussion here:
https://community.powerbi.com/t5/Desktop/Row-Level-Security-All-Users/m-p/253154
6 Replies
- AnonymousNot applicable
HI harshagraj,
You can refer to the following link to know how to set a dynamic RLS based on username:
Solved: RLS with UserName() - Microsoft Power BI Community
Notice: please create a measure with USERNAME and USERPRINCIPALNAME functions to confirm which one is suitable for your user table information.
Difference between USERNAME() and USERPRINCIPALNAME() in Power BI Dax - SPGuides
Regards,
Xiaoxin Sheng
- amitchandakSuper User
harshagraj , You can use USERPRINCIPALNAME only in a measure. I doubt you can use that in a column
- harshagrajPost Partisan
Thanks for the reply but how do i solve this problem?
I also tried creating a role like NAME<>LOOKUP(NAME,EMAIL,USERPRINCIPALNAME())
This is also not working properly because i dont have a speicific AD gropu to assign.
- harshagrajPost Partisan
Also if i have to create a measure then how do i aggregate Name column?
If(???(Name)=USERPRINCIPALNAME(),1,0)
Kindly help.
- harshagrajPost Partisan
Hello can someone help on this topic
Greg_Deckler AlexisOlson PhilipTreacy v-zhangti
- AlexisOlsonSuper User
You can create an RLS role with the rule
[email] <> USERPRINCIPALNAME()Once you have created a role, anyone you want to view the report must be assigned to a role. This is the intended functionality and there isn't a way to avoid assigning roles if you want to use RLS.
See the documentation and prior discussion here:
https://community.powerbi.com/t5/Desktop/Row-Level-Security-All-Users/m-p/253154