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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
miken72
Frequent Visitor

Conditional formatting - highlighting the bar in a graph that belongs to the userprincipalname()

Hello

 

I have a report that uses RLS, so the person running the report sees the data they are allowed to view according to RLS rules, and the value of their email retreived from the userprincipalname() function. This works great.

In the report I have another barchart that shows data for all users (including the user who is logged in). I would like it to be conditionally formatted so that the bar relating to the logged-in user (i.e. the unique ID linked to the email value taken from the userprincipalname()) is highlighted in a different colour compared to all the other bars, so that the user/reader of the report can easily see where they are in the chart compared to all the others.

For example, this yellow-ringed bar belongs to the currently logged-in user (the userprincipalname() holds the user's email address they are logged-in with). Can we have conditional formatting to display that bar in different colours compared to the other users' bars?

ExamplePowerBIbarChartToConditionallyFormat.PNG

 


Can this be done? 

I have a table that holds only the value of the current logged-in user's ID but when I try to use the field from this table in a measure (to be used to conditionally format the appropriate bar in the chart)  I get the message that there are many user ID values in the table, and not just the one ID that I see in when running the report as the user.

If I use a card to display a measure that gets the ID from the above-mentioned table displays the correct user ID and only that unique ID.

Can this highlighting the current user / logged-in user in a chart (even for example the point relating to the logged-in user in a scatter diagram) be done?

Thanks in advance.

1 ACCEPTED SOLUTION

Hello!

Thank you for you help. 

The issue is that I do not have the email address in the fact table that the graph reads from.

Instead it is in a table (B) linked to the Fact table (A) by user ID (1 "BehID" in table B to many "Behandlare ID" in table A):

miken72_0-1701860773252.png

 



I created the following measure on the fact table and used it in the conditional formatting on the Fact table's columns, but it doesn't change the colour of the column relating to the currently logged-in user to pink.


HighlightUsersColumnMeasure2 = SWITCH(TRUE(),
          SELECTEDVALUE('EmailBehID'[Emailadress]) = USERPRINCIPALNAME() , "pink",
          SELECTEDVALUE('EmailBehID'[Emailadress]) <> USERPRINCIPALNAME(), "blue"
)

Would I need the email address field in the Fact table for this conditional formatting to work? 
I'd rather not have it there, and instead display the user ID (behandlare ID). 

I am right in thinking that I could have it there but hide it or is there another way to solve this without having the email address in the Fact table (table A)?

Thanks again 




View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi,  @miken72 

You can create a measure as follows.

 

Measure = SWITCH(TRUE(), 
          SELECTEDVALUE('Table (2)'[name]) = USERPRINCIPALNAME() , "pink", 
          SELECTEDVALUE('Table (2)'[name]) <> USERPRINCIPALNAME(), "blue" 
) 

 

 

Then select the button as shown.

vxuxinyimsft_3-1701833126854.png

 

Then add the conditions as shown.

vxuxinyimsft_1-1701832808589.png

 

 

vxuxinyimsft_2-1701832828710.png

 

Is this the result you expect?

 

 

Best Regards,

Yuliax

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

Hello!

Thank you for you help. 

The issue is that I do not have the email address in the fact table that the graph reads from.

Instead it is in a table (B) linked to the Fact table (A) by user ID (1 "BehID" in table B to many "Behandlare ID" in table A):

miken72_0-1701860773252.png

 



I created the following measure on the fact table and used it in the conditional formatting on the Fact table's columns, but it doesn't change the colour of the column relating to the currently logged-in user to pink.


HighlightUsersColumnMeasure2 = SWITCH(TRUE(),
          SELECTEDVALUE('EmailBehID'[Emailadress]) = USERPRINCIPALNAME() , "pink",
          SELECTEDVALUE('EmailBehID'[Emailadress]) <> USERPRINCIPALNAME(), "blue"
)

Would I need the email address field in the Fact table for this conditional formatting to work? 
I'd rather not have it there, and instead display the user ID (behandlare ID). 

I am right in thinking that I could have it there but hide it or is there another way to solve this without having the email address in the Fact table (table A)?

Thanks again 




Hello again.

I solved it by adding the email address to the Fact table, having the measure check that field, and then hiding the email address column in the table.

It works now - thanks again, great stuff!

miken72_0-1701867643553.png

 



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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