Forum Discussion
Dynamic Average (calendar year to date)
- 6 years ago
Hi, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create calculated columns and a measure as below to get the average of Sales from January2020 until the latest month(August) that year.
Calculated column:Year = YEAR('Table'[Date]) Month = MONTH('Table'[Date]) YearMonth = YEAR('Table'[Date])*100+MONTH('Table'[Date])Measure:
Avg = DIVIDE( CALCULATE( SUM('Table'[Sell Out(MSU)]), FILTER( ALL('Table'), [Year]=YEAR(TODAY())&& [Month]>=1&& [Month]<=MONTH(TODAY()) ) ), CALCULATE( DISTINCTCOUNT('Table'[YearMonth]), FILTER( ALL('Table'), [Year]=YEAR(TODAY())&& [Month]>=1&& [Month]<=MONTH(TODAY()) ) ) )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
it didnt work 😞
mhossain
this is my table set, I am trying to get the average of Sales from January2020 until the latest month that year.
Hi, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create calculated columns and a measure as below to get the average of Sales from January2020 until the latest month(August) that year.
Calculated column:
Year = YEAR('Table'[Date])
Month = MONTH('Table'[Date])
YearMonth = YEAR('Table'[Date])*100+MONTH('Table'[Date])
Measure:
Avg =
DIVIDE(
CALCULATE(
SUM('Table'[Sell Out(MSU)]),
FILTER(
ALL('Table'),
[Year]=YEAR(TODAY())&&
[Month]>=1&&
[Month]<=MONTH(TODAY())
)
),
CALCULATE(
DISTINCTCOUNT('Table'[YearMonth]),
FILTER(
ALL('Table'),
[Year]=YEAR(TODAY())&&
[Month]>=1&&
[Month]<=MONTH(TODAY())
)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.