Showing results for 
Search instead for 
Did you mean: 
Not applicable



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. 



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")



Please refer to this pbix

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

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.


Super User
Super User

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


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

New Power BI Features
Field Parameters :
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors