Forum Discussion

BIswajit_Das's avatar
BIswajit_Das
Impactful Individual
2 years ago
Solved

POWER BI MATRIX

Hello 
If there a table like

codep_no`namenumarea
sa1a1a
sa1b2b
sa1c3a
sa1d4a
sa1e5b
sa1f6a
sa1g7b
sa1h8c
sa1i9c
sa2j10b
sa2k11b
sa2l12c
sa2m13a
sa2n14c

with this data we can create a matrix like

  area   
p_noabcd 
1432 count of num
2123  

Here I want to add conditional color formatting to highlight the max value and add color based on area 
i.e
For
a = Blue
b = Black

c = yellow
and so on.....
i.e.

Here the Similar used DAX

max_color =
VAR _max_count =  // [@COM_MAXVALCOUNT] Measure to compair with
    MAXX (
        SUMMARIZE ( 'xyz', 'xyz'[area], "count", COUNTROWS ( 'xyz' ) ),
        [count]
    )
VAR _winner =

    MAXX (
        FILTER (
            SUMMARIZE ( 'xyz', 'xyz'[area], "@count", COUNTROWS ( 'xyz' ) ),
            [@count] = _max_count
        ),
        'xyz'[area]
    )
// VAR _winner = [@COM_WINPARTY]
RETURN
SWITCH(TRUE(),
_winner = "BJP" && _max_count = [@COM_MAXVALCOUNT],"BLACK",
_winner = "AD(S)" && _max_count = [@COM_MAXVALCOUNT],"BLUE",""
)
Thanks & Regards...



  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi BIswajit_Das ,

    Sorry for being late, please change the DAX into this:

    Measure = var _tab=SUMMARIZE(ALLSELECTED('Sheet18'[RES]),'Sheet18'[RES], "@sumvalue",CALCULATE(COUNT(Sheet18[NUM])))
    var _max= maxx( _tab,[@sumvalue])
    var _area=SELECTEDVALUE('Sheet18'[RES])
    return  SWITCH(TRUE(),COUNT('Sheet18'[NUM])=_max&&_area="a","Blue", COUNT('Sheet18'[NUM])=_max&&_area= "b","Black",COUNT(Sheet18[NUM])=_max&&_area="c","Yellow")

    The final output is below:

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

5 Replies