Forum Discussion

miken72's avatar
miken72
Icon for Helper I rankHelper I
2 years ago
Solved

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?

 


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.

  • miken72's avatar
    miken72
    2 years ago

    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):

     



    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 




3 Replies

  • Anonymous's avatar
    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.

     

    Then add the conditions as shown.

     

     

     

    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.

    • miken72's avatar
      miken72
      Icon for Helper I rankHelper I

      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):

       



      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 




      • miken72's avatar
        miken72
        Icon for Helper I rankHelper I

        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!