Forum Discussion
Average horizontal Line across the Bar chart
- 4 months ago
Hey thiamhuat2026,
To add a dynamic average line to your bar chart, first create this measure:
Avg EDU NoCarpark (%) = AVERAGEX( VALUES('tc_merged_gold'[TOWN_COUNCIL]), [EDU_NoCarpark (%)] )Then, go to Visualizations > Analytics (search glass icon) > Y-axis constant line > Value (select above measure) and click ok.
Looking at your base measure, SELECTEDVALUE() returns blank the moment more than one distinct value exists in the filter context, silently breaking the average measure. MAX() always returns a single value regardless, making your calculation reliable across all filter and slicer combinations.
EDU_NoCarpark (%) = DIVIDE( COUNT('tc_merged_gold'[CASE_ID]), CALCULATE(MAX('tc_merged_gold'[EDU_without_Carpark])) ) * 100Hope that helps.
Best,
Harshit
Hi thiamhuat2026 ,
You could create a measure that calculates the average value and then pass that measure to the 'Value' in Y-Axis Constant Line using the fx button and in the Field value , select the measure in the 'What field should we base this on?' section.
Hope it helps!
I should say mine is a bit tricky.. those values on each individual bar chart is based on some measure
- stoic-harsh4 months ago
Super User
Hey thiamhuat2026,
To add a dynamic average line to your bar chart, first create this measure:
Avg EDU NoCarpark (%) = AVERAGEX( VALUES('tc_merged_gold'[TOWN_COUNCIL]), [EDU_NoCarpark (%)] )Then, go to Visualizations > Analytics (search glass icon) > Y-axis constant line > Value (select above measure) and click ok.
Looking at your base measure, SELECTEDVALUE() returns blank the moment more than one distinct value exists in the filter context, silently breaking the average measure. MAX() always returns a single value regardless, making your calculation reliable across all filter and slicer combinations.
EDU_NoCarpark (%) = DIVIDE( COUNT('tc_merged_gold'[CASE_ID]), CALCULATE(MAX('tc_merged_gold'[EDU_without_Carpark])) ) * 100Hope that helps.
Best,
Harshit
- stoic-harsh4 months ago
Super User
Below is the result (I took a sample data of Singapore Town Councils from internet):
Best,
Harshit
- thiamhuat20264 months ago
Helper III
can you share the link of where you get the sample data of Singapore Town Councils from internet?