Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Conditional Formatting in Total and SubTotal

Hey guys,   I needed help here on this conditional formatting on this matrix table. I needed this dax measure to give me the best 3 results in green and the worst 3 results in red.   What is happ...
  • MFelix's avatar
    MFelix
    5 years ago

    Hi Anonymous ,

     

    That has to do with the way I setup the formula that was using HASONEVALUE since Agosto was only one value it returned the green.

     

    I have change the formulas to:

     

    Ranking_asc = 
    IF (
        ISINSCOPE( 'Folha1'[Técnico] ),
        RANKX ( ALLSELECTED( 'Folha1'[Técnico]),CALCULATE(SUM(Folha1[Valor])),, ASC ),
        RANKX ( ALLSELECTED(Folha1[Mês], Folha1[MonthNo]),CALCULATE(SUM(Folha1[Valor])),, ASC )
    )
    
    Ranking_desc = 
    
    IF (
        ISINSCOPE(  'Folha1'[Técnico] ),
        RANKX ( ALLSELECTED( 'Folha1'[Técnico]),CALCULATE(SUM(Folha1[Valor])),, DESC ),
        RANKX ( ALLSELECTED( Folha1[Mês], Folha1[MonthNo]),CALCULATE(SUM(Folha1[Valor])),, DESC )
    )
    
    Cores = 
    IF(ISINSCOPE(Folha1[Mês]) || ISINSCOPE(Folha1[Técnico]),
        SWITCH ( TRUE (), [Ranking_desc] <= 3, "Green", [Ranking_asc] <= 3, "red" )
    )

     

    This changes will also make it work when you have filters on your data that the previous version did not had.

    PBIX file attach.