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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BIswajit_Das
Resolver III
Resolver III

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.
ccc.png
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...



1 ACCEPTED SOLUTION

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:

vjunyantmsft_0-1705905951852.png

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.

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@BIswajit_Das , If you want on Area- a, b, c then you need to use a measure given below in conditional formatting using the field value option

 

Switch(Max(Table[Area]) ,

"a", "Blue",

"b", "black",

"c", "Yellow",

// add other 

"green"

)

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...
https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

Hello @amitchandak thanks for responding.
But If possible can you give an example regarding this query
i. e How to add color formating on a matrix based on the above senario.
Thanks & Regards...

Hi @BIswajit_Das ,

Please refer to the steps:
I create a measure by using this DAX:

Measure 2 = var _tab=SUMMARIZE(ALLSELECTED('Table (2)'[area]),'Table (2)'[area], "@sumvalue",CALCULATE(SUM('Table (2)'[value])))
var _max= maxx( _tab,[@sumvalue])
var _area=SELECTEDVALUE('Table (2)'[area])
return  SWITCH(TRUE(),sum('Table (2)'[Value])=_max&&_area="a","Blue", sum('Table (2)'[Value])=_max&&_area= "b","Black",sum('Table (2)'[Value])=_max&&_area="c","Yellow")

vjunyantmsft_0-1705653162911.png
vjunyantmsft_1-1705653403631.png


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.

Hello@v-junyant-msft 
Thanks for responding but can you edit the measure for this data
PCNONUMRES

11A
12A
13B
14A
25B
26C
27A
28B
39C
310A
311C
312C

here the measure is like 
sa.png
i.e
In rows - pcno

columns - res

values - count(num)
Thanks & regards..

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:

vjunyantmsft_0-1705905951852.png

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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