This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi All,
I have monthly sales by city from 1 Jul 2017 to 1 Aug 2021.
I would like to add 4 year average sales by city to my graph(like red line in the graph) Please help!
I tried to use similar dax I found in community , but did not work because...
It showed error when I typed Sales[Date].[Year]
I also do not know how to filter by city....
Measure =
AVERAGEX (
SUMMARIZE (
FILTER (
Sales,
YEAR ( Sakes[Date] )
>= YEAR ( TODAY () ) - 4
&& YEAR ( Sales[Date] ) < YEAR ( TODAY () )
),
Sales[Date].[Year]
),
CALCULATE ( SUM ( Sales[Sales] ) )
)
All the best,
Paris
Hi, @paris
For calculating the average, you can try the following two schemes.
1. Calculated column
Average =
CALCULATE (
AVERAGE ( Sales[Sales] ),
FILTER ( Sales, Sales[Month] = EARLIER ( Sales[Month] ) )
)
2. Measure
Measure =
CALCULATE (
AVERAGE ( Sales[Sales] ),
FILTER ( ALL ( Sales ), Sales[Month] = MAX ( Sales[Month] ) )
)
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@paris
Can you use the following measure?
AVERAGEX (
SUMMARIZE (
FILTER (
all(Sales[Year]),
Sales[Year] >= YEAR ( TODAY () ) - 4 && Sales[Year] < YEAR ( TODAY () )
),
Sales[Year]
),
CALCULATE ( SUM ( Sales[Sales] ) )
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi Fowmy,
Thank you for your reply. I tried your measure but it shows same number as original sales except there is no data in 2021.
I wanted to add average for 2017 - 2020 only so I also tried below but the result is the same number as original sales except there is no data in 2021.
AVERAGEX (
SUMMARIZE (
FILTER (
all(Sales[Year]),
Sales[Year] >= 2017 && Sales[Year] < 2021
),
Sales[Year]
),
CALCULATE ( SUM ( Sales[Sales] ) )
)
Thank you again and hope you can help me further.
All the best,
Paris
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 30 | |
| 26 | |
| 25 | |
| 22 | |
| 13 |
| User | Count |
|---|---|
| 60 | |
| 50 | |
| 26 | |
| 20 | |
| 19 |