Forum Discussion
robdwright65
3 months agoNew Member
Bar and Line Chart With Date – Fixing Average Line Not Respecting Date Filters in Stacked Co
Hi, I hope someone can help. I was trying to add an average line to a stacked column chart in Power BI. Initially, the measure either produced a non-flat line or didn’t match the expected averag...
- 3 months ago
I've just found the issue.
I was using the code above (with the flat average line).
However, I found I was using two different dates, in the code
DIM_Calendar[Date]In the chart I was using,FACT_BadgeRecordsSlim[Date] - I've now changed this and it has removed the months that are filtered out.Hope this helps someone else.ThanksRob
robdwright65
3 months agoNew Member
This updated code provides the flat Average Line, but the date filter is not honoured.
msAvgFilterRank =
VAR AvgValue =
CALCULATE(
AVERAGEX(
ALLSELECTED(DIM_Calendar[Date]),
CALCULATE(
SUM(FACT_BadgeRecordsSlim[Count]),
FACT_BadgeRecordsSlim[Count] > 0,
FACT_BadgeRecordsSlim[RankFilter] = TRUE()
)
),
REMOVEFILTERS(FACT_BadgeRecordsSlim)
)
RETURN
AvgValue