Forum Discussion
USERNAME() function DAX
- 9 years ago
Hi Tucker,
According to the official document, the format of user name in Service is UPN, which looks like an email address [email protected]. So,
1. The list of user names should be UPN, which we can find out the exact format in the Service with function userprincipalname().
2. We should use userprincipalname() in the role we defined in Desktop.
>>Within the Power BI service, username() and userprincipalname() will both return the user's User Principal Name (UPN). This looks similar to an email address.
My test:
formula of a role: IF ( USERPRINCIPALNAME () = "[email protected]", [Column1] < 1000, [Column1] = 0 )Best Regards!
Dale
Hi Tucker,
According to the official document, the format of user name in Service is UPN, which looks like an email address [email protected]. So,
1. The list of user names should be UPN, which we can find out the exact format in the Service with function userprincipalname().
2. We should use userprincipalname() in the role we defined in Desktop.
>>Within the Power BI service, username() and userprincipalname() will both return the user's User Principal Name (UPN). This looks similar to an email address.
My test:
formula of a role:
IF (
USERPRINCIPALNAME () = "[email protected]",
[Column1] < 1000,
[Column1] = 0
)
Best Regards!
Dale
- Tucker9 years ago
Helper I
Hi Dale,
Thanks for you reply, I have got this far but after playing all day yesterday but still have an issue.
So in my data I have the email address (UPN) of the user so have created a role and said [eMailAddress] = username() in the desktop. Published up to my Workspace and in Security selected "Test as Role" and I see exactly what I'd expect.
The issue then comes when I create a Content Pack and share with a O365 group (having added the user names to the RLS in the dataset), I then go into the group and "Get Data" when I then view the report in the group I can see everything.
I have read that the users need to be "Read Only" in the group which they are but I'm the Admin so don't know if that makes a difference. I got a collegue to test and he see nothing just blank reports.
Thanks again for your reply and if you know what I'm doing wrong please let me know cause I've been at this for weeks!!
Cheers Toby
- v-jiascu-msft9 years ago
Microsoft Employee
Hi Toby,
I wonder if you have published an App. If so, everyone has to get a role even no filter applied to him/her. This is from my test. Have a try please.
Best Regards!
Dale
- Tucker9 years ago
Helper I
Thanks, please forgive me as I'm very new to Apps and have always used Content Packs which it looks like they are going anyway.
So I created a new App Workspace and add my team members (this has created a new O365 Group as well which is frustrating as I already have my O365 groups with shared calendars, SharePoint sites etc!)
I then Published my PBIX file up to the new Workspace instead of via My Workspace and it appears, however this still doesn't seem to have solved my issue but I may be doing something wrong
Cheers TB