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

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.