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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

undefined

Hello,

How can I write a DAX code to compare each value of the graph shown with its group average value? My intention would be to compare each value with its group average value and give it a colour accorfing to the result. 

azmuh_0-1647263565591.png

 

4 REPLIES 4
Anonymous
Not applicable

Thanks for the reply @amitchandak . So, I want to write an IF condition to compare each of my forecast value with the average(IF forecast value >group average, "red", "green").  For this, I am not able to mention the "forecast values" part in the IF statement as DAX does not show suggestions as it normally shows. From my understaning it could be because the forecast value is not a measure. How can I write the code in this case?

Hi @Anonymous ,

 

You cannot apply color conditional formatting  in a line chart. Try using line and stacked column chart .

group average = CALCULATE(AVERAGE('Table'[value]),ALLEXCEPT('Table','Table'[Product]))
Color = IF(SUM('Table'[value])>[group average],"red","green")

Vlianlmsft_0-1647501100923.png

 

Please refer to this pbix


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

Anonymous
Not applicable

Hi Liang

Thank you for our time and patience. Since my data set contains nearly 40 different products, the formula you suggested does not seem to work, as it shows the same average for whichever categoary of product I select(each product has a different average forecast value).

I hope I have communicated the issue clearly. Please let me know if you need more information.

Thanks

amitchandak
Super User
Super User

@Anonymous , You can get constant line using the same measure

 

Calculate([Measure], all(Table[Group]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors