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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.