Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Dear colleagues
I have a column chart with a date on x-axis and count of orders on the y-axis. I would like to display an average line over the bars, which displays an average value of the displayed bars values.
An easy solution is to switch to “clustered column chart”, which allows to enable average line on the “further analysis” tab. Everything looks good:
until the x-axis shows only one period (one day, one month or one year). Then the avg line is distracting and actually useless:
So my question is, how to set a column chart with an average line, which disappears, when the chart shows only one value/bar.
See example AVG line in stacked column chart in case of one value.pbix.
I believe in a measure, which can detect number of periods displayed and which calculates the average of the bar values or sets the line value to blank based on count of displayed periods. One constrain is, that the date x-axis is managed by field parameters.
Thank You very much for any hint.
Zdenek Moravec
Cesky Krumlov, Czechia
Solved! Go to Solution.
Hi @zdenek_moravec ,
For this you need to create a measure with the following syntax:
Average Line = SWITCH(
TRUE(),
SELECTEDVALUE(DateParameters[DateParameters Order]) = 0 &&
COUNTROWS(FILTER(
SUMMARIZE(
DIM_Calendar,
DIM_Calendar[Date],
"C", [CountOfOrders]
),
[C] <> BLANK()
)) > 1,
AVERAGEX(
ALLSELECTED(DIM_Calendar[Date]),
[CountOfOrders]
),
SELECTEDVALUE(DateParameters[DateParameters Order]) = 1&&
COUNTROWS(FILTER(
SUMMARIZE(
DIM_Calendar,
DIM_Calendar[Month],
"C", [CountOfOrders]
),
[C] <> BLANK()
)) > 1, AVERAGEX(
ALLSELECTED(DIM_Calendar[Month]),
[CountOfOrders]
),
SELECTEDVALUE(DateParameters[DateParameters Order]) = 2 &&
COUNTROWS(FILTER(
SUMMARIZE(
DIM_Calendar,
DIM_Calendar[Year],
"C", [CountOfOrders]
),
[C] <> BLANK()
)) > 1, AVERAGEX(
ALLSELECTED(DIM_Calendar[Year]),
[CountOfOrders]
)
, BLANK())
Then add the value has a constant line and not an average.
Be aware that you may need to recreate your chart from scratch since the creation of other line usually mess up the visual.
See file attach
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @zdenek_moravec ,
For this you need to create a measure with the following syntax:
Average Line = SWITCH(
TRUE(),
SELECTEDVALUE(DateParameters[DateParameters Order]) = 0 &&
COUNTROWS(FILTER(
SUMMARIZE(
DIM_Calendar,
DIM_Calendar[Date],
"C", [CountOfOrders]
),
[C] <> BLANK()
)) > 1,
AVERAGEX(
ALLSELECTED(DIM_Calendar[Date]),
[CountOfOrders]
),
SELECTEDVALUE(DateParameters[DateParameters Order]) = 1&&
COUNTROWS(FILTER(
SUMMARIZE(
DIM_Calendar,
DIM_Calendar[Month],
"C", [CountOfOrders]
),
[C] <> BLANK()
)) > 1, AVERAGEX(
ALLSELECTED(DIM_Calendar[Month]),
[CountOfOrders]
),
SELECTEDVALUE(DateParameters[DateParameters Order]) = 2 &&
COUNTROWS(FILTER(
SUMMARIZE(
DIM_Calendar,
DIM_Calendar[Year],
"C", [CountOfOrders]
),
[C] <> BLANK()
)) > 1, AVERAGEX(
ALLSELECTED(DIM_Calendar[Year]),
[CountOfOrders]
)
, BLANK())
Then add the value has a constant line and not an average.
Be aware that you may need to recreate your chart from scratch since the creation of other line usually mess up the visual.
See file attach
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHello @MFelix , it works like a charm! I have to debug the DAX many times yet to fully understand, anyway Your solution is nice and easy. Thank You very much!
ChatGPT review for reference:
SWITCH(TRUE(), condition1, result1, condition2, result2, ...)
SELECTEDVALUE(DateParameters[DateParameters Order])
Summarization with SUMMARIZE()
Averaging with AVERAGEX()
Default Case (BLANK())
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 43 | |
| 41 | |
| 21 | |
| 17 |