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
Karthik50
Frequent Visitor

Power-BI Scatter plot dynamic color based on Average or Median value..

Hi Community,

The excel data source is below:

Karthik50_0-1712650884634.png


The scatter chart, based on the above excel is below:

Karthik50_0-1712651169225.png

Questions:
=> For the Average Line value of 766.66, the value is got by dividing the total sales (2300) by count of months (3) - is this correct?
=> For the Median Line value of 800, how is this value got? Can you give me the Dax equivalent?
=> I want to color dots less than the average line value or less than the median line value, with one color. How can I write this measure?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Karthik50 ,

 

Question1:

This is correct and will add up all the values in the month divided by the deduplication. It doesn't change dynamically based on different time periods, you can create a measure if you want to find a monthly average that isn't deduplicated or change dynamically based on the slicer selection.

Use the Analytics pane in Power BI Desktop - Power BI | Microsoft Learn

Question2:

This value is the median value of adding up according to the [Month] grouping

vyangliumsft_0-1712724195453.png

 

Measure_Median =
var _table=
SUMMARIZE(ALL('Table'),'Table'[Month],"sum",SUM('Table'[Sales]))
return
MEDIANX(_table,[sum])

 

vyangliumsft_0-1712724276067.png

Question3:

Create measure:

Color_median=
var _sum=SUM('Table'[Sales])
var _table=
SUMMARIZE(ALL('Table'),'Table'[Month],"sum",SUM('Table'[Sales]))
return
SWITCH(
    TRUE(),
    _sum<=MEDIANX(_table,[sum]),"red","yellow")
Color_avg =
var _sum=SUM('Table'[Sales])
var _table=
SUMMARIZE(ALL('Table'),'Table'[Month],"sum",SUM('Table'[Sales]))
return
SWITCH(
    TRUE(),
    _sum<=AVERAGEX(_table,[sum]),"red","yellow")

Format visual – Markers – Color –fx:

vyangliumsft_1-1712724287426.png

vyangliumsft_2-1712724287426.png

Select [Color_median] or [Color_avg]

vyangliumsft_3-1712724325897.png

vyangliumsft_4-1712724325898.png

 

Best Regards,

Liu Yang

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

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi  @Karthik50 ,

 

Question1:

This is correct and will add up all the values in the month divided by the deduplication. It doesn't change dynamically based on different time periods, you can create a measure if you want to find a monthly average that isn't deduplicated or change dynamically based on the slicer selection.

Use the Analytics pane in Power BI Desktop - Power BI | Microsoft Learn

Question2:

This value is the median value of adding up according to the [Month] grouping

vyangliumsft_0-1712724195453.png

 

Measure_Median =
var _table=
SUMMARIZE(ALL('Table'),'Table'[Month],"sum",SUM('Table'[Sales]))
return
MEDIANX(_table,[sum])

 

vyangliumsft_0-1712724276067.png

Question3:

Create measure:

Color_median=
var _sum=SUM('Table'[Sales])
var _table=
SUMMARIZE(ALL('Table'),'Table'[Month],"sum",SUM('Table'[Sales]))
return
SWITCH(
    TRUE(),
    _sum<=MEDIANX(_table,[sum]),"red","yellow")
Color_avg =
var _sum=SUM('Table'[Sales])
var _table=
SUMMARIZE(ALL('Table'),'Table'[Month],"sum",SUM('Table'[Sales]))
return
SWITCH(
    TRUE(),
    _sum<=AVERAGEX(_table,[sum]),"red","yellow")

Format visual – Markers – Color –fx:

vyangliumsft_1-1712724287426.png

vyangliumsft_2-1712724287426.png

Select [Color_median] or [Color_avg]

vyangliumsft_3-1712724325897.png

vyangliumsft_4-1712724325898.png

 

Best Regards,

Liu Yang

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

 

 

Sorry to add to an existing "accepted solution" but I had a query: Can you tell me how line below works?

 _sum<=AVERAGEX(_table,[sum]

 
The variable "_sum" is the sum of total sales. For the attached example, it would be over 2000. But in the above code, is the "Row Context" impacting the value of the variable "_sum" when it is compared against "Averagex" of the column in the table generated throough the "summarize" function? If so, what would be the value of "_Sum" as it iterates over a summarized table of three unique months?

For those who are looking for a similar solution, I used "Calculate" function to get the right value I require. More on this, in another post of mine, here.

Thanks for the detailed info. This helps!

 

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