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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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