Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Conditional formatting - top 3 clustered column chart

Hello all,   I'm trying to get a top 3 clustered column chart where I can conditional format the following: #1: color gold #2: color silver #3: color bronz    The data is as followed: ...
  • johncolley's avatar
    4 years ago

    Hi Anonymous ,

     

    The switch statement is the way to go, but need a rank column to make it work. 

     

    This thread details a few ways to go about ranking: https://community.powerbi.com/t5/Desktop/Ranking-a-column-in-a-table/td-p/1436672 

     

    I followed the index column within power query and called it 'Descending Rank' and then used the following measures:

    Rank = SELECTEDVALUE('Top 3'[Descending Rank])

     

    Colouringtop3 = 
    var firstplace = [Rank] = 1
    var secondplace = [Rank] = 2
    var thirdplace = [Rank] = 3
    var result = SWITCH(
    TRUE(),
    firstplace, "Gold",
    secondplace, "Silver",
    thirdplace, "Brown", "Black")
    return
    result

     

    I hope this solves your problem and if it does please mark it as a solution!