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
em12963
Helper I
Helper I

Highlighting a highest and lowest colour on bar graph using DAX and conditional formatting

Hi there

 

I am trying to highlight a highest(green) and lowest(red) colour on my stacked column chart visual. 

My ideal visual should like the image attached whereby D is the group with the largest quantity and so is green in colour, and B is red as it's the lowest quantity, the rest are blue.graph.png

 

I have created a new measure:

Highest / Lowest value =
var highestvalue = MAXX(ALLSELECTED('Table'[Group]),CALCULATE(SUM('Table'[Quantity])))
var lowestvalue = MINX(ALLSELECTED('Table'[Group]),CALCULATE(SUM('Table'[Quantity])))
return
SWITCH(CALCULATE(SUM('Table'[Quantity])),
highestvalue , "#73B761",
lowestvalue , "#D64550",
"#879092" )
 
I added that measure in the conditional settings in the Format settings chart -> Columns -> Colors fx part.
 
However, my dax doesn't seem to be working. It's making every column group green. 
Help. 
1 ACCEPTED SOLUTION

Hi , I realised that the code actually worked. What was stopping it from working was that I had previously had the 'Group' column sorted by another column in the data section. After removing that, then my colours appeared in the visual. 

 

Attached is the report

https://1drv.ms/u/s!AldfJ8BDTJeOnXwCB34BxFF3cTIA?e=HnpVTT

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @em12963,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi , I realised that the code actually worked. What was stopping it from working was that I had previously had the 'Group' column sorted by another column in the data section. After removing that, then my colours appeared in the visual. 

 

Attached is the report

https://1drv.ms/u/s!AldfJ8BDTJeOnXwCB34BxFF3cTIA?e=HnpVTT

HI @em12963,

I'm glad to hear you find the reason and share the solution here, they will be help others who faced the similar issues.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help 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.