This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Dear,
I am trying to calculate the average amount for "n" years and months, as shown in the image attached. However, I have not found any right way to do it. Any advice or trick you can give me?
Thank you!
Regards,
Solved! Go to Solution.
Hi, @DanCasSan
Based on your description, I created data to reproduce your scenario.
Table:
Calendar:
Calendar = CALENDARAUTO()
There is a one-to-many relationship between two tables. I create a 'Month-Year' column in 'Calendar' table.
Month-Year =
IF(
MONTH('Calendar'[Date])<10,
YEAR('Calendar'[Date])&"0"&MONTH('Calendar'[Date]),
YEAR('Calendar'[Date])&MONTH('Calendar'[Date])
)
You may create a measure as follows.
Average =
IF(
ISFILTERED('Calendar'[Month-Year]),
BLANK(),
DIVIDE(
CALCULATE(
SUM('Table'[Value]),
ALL('Calendar'[Month-Year])
),
CALCULATE(
DISTINCTCOUNT('Calendar'[Month-Year]),
ALLSELECTED('Calendar')
)
)
)
Result:
If I misunderstand your thoughts, please show us your expected result and sample data. Do mask sensitive data before uploading. Thanks
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members to find it more quickly.
Hi, @DanCasSan
Based on your description, I created data to reproduce your scenario.
Table:
Calendar:
Calendar = CALENDARAUTO()
There is a one-to-many relationship between two tables. I create a 'Month-Year' column in 'Calendar' table.
Month-Year =
IF(
MONTH('Calendar'[Date])<10,
YEAR('Calendar'[Date])&"0"&MONTH('Calendar'[Date]),
YEAR('Calendar'[Date])&MONTH('Calendar'[Date])
)
You may create a measure as follows.
Average =
IF(
ISFILTERED('Calendar'[Month-Year]),
BLANK(),
DIVIDE(
CALCULATE(
SUM('Table'[Value]),
ALL('Calendar'[Month-Year])
),
CALCULATE(
DISTINCTCOUNT('Calendar'[Month-Year]),
ALLSELECTED('Calendar')
)
)
)
Result:
If I misunderstand your thoughts, please show us your expected result and sample data. Do mask sensitive data before uploading. Thanks
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members to find it more quickly.
You're the best! It worked perfectly.
Regards,
Daniel Castillo
Prefer to have date table with month year
AVERAGEX(summarize(Table,table[Month year],"_sum", SUM ( Table[Amount] )),"_sum")
AVERAGEX(values(table[Month year]),"_sum", SUM ( Table[Amount] )),"_sum")
AVERAGEX(summarize(Table,Date[Month year],"_sum", SUM ( Table[Amount] )),"_sum")
AVERAGEX(values(Date[Month year]),"_sum", SUM ( Table[Amount] )),"_sum")
Also refer :https://community.powerbi.com/t5/Desktop/SUM-of-AVERAGE/td-p/197013
Hello, thank you for your prompt response, I have done the following (attached code), but, it gives me the general average and, that is not what I need; what I need is that this average be based on period, storage and code as is to the image I put at the beginning.
SUMAVERA =
AVERAGEX(
SUMMARIZE(
DS_MPSMRP,
DS_MPSMRP[PERIODO],
DS_MPSMRP[PLWRK],
DS_MPSMRP[MATNR],
"AVERASUM",CALCULATE(SUM(DS_MPSMRP[MENGE]),FILTER(DS_MPSMRP,DS_MPSMRP[BWART]="261"))
),
[AVERASUM]
)
The formula seems fine as per the screenshot shared.
Can you share sample data and sample output. If possible please share a sample pbix file after removing sensitive information.Thanks.
Hi @DanCasSan ,
Try this:
Average =
AVERAGEX ( VALUES ( 'Table'[YYYYMM] ), SUM ( 'Table'[Amount] ) )
Check out the April 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 | |
| 24 | |
| 23 | |
| 17 | |
| 15 |
| User | Count |
|---|---|
| 61 | |
| 36 | |
| 29 | |
| 22 | |
| 21 |