Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Oksie
Regular Visitor

Is it possible to change the value of USERPRINCIPALNAME?

Hello!
I'm trying to set up some kind of custom dynamic RLS. Basically, I want some people to see the report as their bosses. And for that I need to change the value of their userprincipalname() with another value.

 

A have a table with the real login and the new, fake login that they should see the report as. The reason why I need such a complicated desicion is that bosses can only see their department, usually employees can't see this info, but some request it specifically. For some people the new_login is the same as they don't need to have additional permissions.

real_loginnew_login
bossboss
employee1       employee1
employee2boss

 

I am very new to DAX and I really struggle to understand how I can create a RLS rule where I compare the UPN with one value and replace it with another one at the same time. I was thinking about something like:

 

[real_login] = SWITCH(USERPRIPCIPALNAME(), [real_login], [new_login], 0)

 

But it doesn't seem to do the job. I will appreciate any help and thanks in advance.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Oksie , Try a new measure like

 

maxx(filter(Table, Table[real_login] =USERPRIPCIPALNAME()) , [new_login])

View solution in original post

v-yanjiang-msft
Community Support
Community Support

Hi @Oksie ,

According to your description, if boss login, he will see information of boss and employee2. If employee1 login, he will see information of himself. If employee2 login, he will see nothing.

If this is the case, here's my solution.

[new_login] = USERPRINCIPALNAME ()

 

vkalyjmsft_0-1645516750346.png

Then the real_login column connect to other fact tables.

vkalyjmsft_1-1645517144455.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @Oksie ,

According to your description, if boss login, he will see information of boss and employee2. If employee1 login, he will see information of himself. If employee2 login, he will see nothing.

If this is the case, here's my solution.

[new_login] = USERPRINCIPALNAME ()

 

vkalyjmsft_0-1645516750346.png

Then the real_login column connect to other fact tables.

vkalyjmsft_1-1645517144455.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Oksie , Try a new measure like

 

maxx(filter(Table, Table[real_login] =USERPRIPCIPALNAME()) , [new_login])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.