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
Hi!
Very new to PBI! Looking for guidance / help how to do the following logic.
I have a table as shown below. I need to add a new measure called YTD ATT that averages Year-to-Date values of the measure called MONTHLY ATT.
For example:
January 2019, the YTD Att would be 0.1448
In February, it should be 0.1449 (average of January and February MONTHLY ATT)
In March, it should be 0.1591 (average of January to March MONTHLY ATT)
In December, it would have been the average of all MONTHLY ATT values of 2019.
Then for January 2020, it would repeat again.
Thank you!
Solved! Go to Solution.
Hi @mfp32 ,
Since I don't know what your raw data is. I made sample data on my own.
You could see the column of month numbers in my sample data. You need to add a column of month numbers to your table too. You can get the month number using the MONTH function. Or replace the text month with a numeric month with the SWITCH function.
I also created a metric to return to Monthly ATT.
Then the YTD ATT could be created like
YTD ATT = AVERAGEX(FILTER(ALLSELECTED('Table'),[Year]=MAX('Table'[Year])&&[Month Number]<=MAX('Table'[Month Number])),[Monthly ATT])
If you want to round down, add ROUNDDOWN function.
YTD ATT = ROUNDDOWN(AVERAGEX(FILTER(ALLSELECTED('Table'),[Year]=MAX('Table'[Year])&&[Month Number]<=MAX('Table'[Month Number])),[Monthly ATT]),4)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello, I tried to follow your logic but I am getting an error. The MAX function only accepts a column reference as an argument.
In my SAP scrap actuals table I have quantity actuals for FY23/FY24 periods 1-12 in FY23, and 1-6 in FY24. I am trying to get the average of all of those months for quantity. So it would be YTD period 6 would be the history of 18 months for quantity - one number for YTD. I added the month name. My month number = period for my table. I added a quantity measure which is this
DAX below getting error.
Hi @mfp32 ,
Since I don't know what your raw data is. I made sample data on my own.
You could see the column of month numbers in my sample data. You need to add a column of month numbers to your table too. You can get the month number using the MONTH function. Or replace the text month with a numeric month with the SWITCH function.
I also created a metric to return to Monthly ATT.
Then the YTD ATT could be created like
YTD ATT = AVERAGEX(FILTER(ALLSELECTED('Table'),[Year]=MAX('Table'[Year])&&[Month Number]<=MAX('Table'[Month Number])),[Monthly ATT])
If you want to round down, add ROUNDDOWN function.
YTD ATT = ROUNDDOWN(AVERAGEX(FILTER(ALLSELECTED('Table'),[Year]=MAX('Table'[Year])&&[Month Number]<=MAX('Table'[Month Number])),[Monthly ATT]),4)
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have a simialr issue. I need to calculate the Average YTD value for each KPI on a monthly basis starting from 01 July 2025 till date Please refer to the data extraction. Please can you help with creating a dax formula? To create the formule, should I use the Calculated column option?
| KPI | Month | Month Actual | YTD | |
| Operations response and readiness compliance | Mar-25 | 100 | ||
| 5 Year plan compliance | Mar-25 | 107 | ||
| Maintenance Workshop Compliance | Mar-25 | 95.36 | ||
| Recordable Cases | Mar-25 | 100 | ||
| EBS Health index | Mar-25 | 100 | ||
| CFC vs budget | Mar-25 | 0 | ||
| Capital Budget Management | Mar-25 | 100 | ||
| Performance against SHE training matrix: | Mar-25 | 63 | ||
| 5 Year plan compliance | Mar-25 | 107 | ||
| Works Emergency Centre availability | Mar-25 | 100 | ||
| Fire breaks | Mar-25 | 100 | ||
| Fire Water Monitoring | Mar-25 | 0 | ||
| Operations response and readiness compliance | Mar-25 | 100 | ||
| Availability of Training Interventions | Mar-25 | 99 |
Dear Stephen Tao,
Thanks for the PBIX file. It was an excellent learning for me as I faced the same issue. However, when I changed the visual to show the Monthly and YTD ATT under the same graphic, the YTD value changed to the Monthly value due to the changes in the context, as shown in the screenshot below. Here is the link to the same PBIX file with the new visual on the next page - It would be great if you could help me with what to change in the YTD measure in the contemporary context. The PBIX File is attached. Thanks.
Hi Stephen Tao,
Thanks for your PBIX file to explain this. I am having the same proplem but this solution is not working for my data model - not sure where I am doing wrong. I wanted to attach the PBIX file and an excel file to show what I want but looks like I cannot attach any file - any idea why I cannot attach any file?
Anyway, I have a transaction table and also a date table in my mdel and I have created the foowing measures:
1.
The Feb vaue should be 13,101 + 13,901 = 27,002 / 2 = 13,501
The March value should be 13,101 + 13,901 + 17,656 = 44,658 / 3 = 14,884
Would you be able to help where I am going wong? Thanks.
@Greg_Deckler , you may like to help also how to write variables in this case - I tried too abve but somehow not getting the expected result.
Appreciate help from the community. Thanks.
Rgds...Aziz
Here is the link to the PBIX file - hope you can access it:
https://1drv.ms/u/s!AgFUe-XGc3QMg9ML54it-XuUgMF8fQ?e=cAD1JJ
and an excel example file Troubleshoot Averge.xlsx
@Anonymous and @Greg_Deckler
Hi @Anonymous and @Greg_Deckler
Finally, I have managed this:
Yeah! This one works for me as well!
@mfp32 Maybe:
YTD Measure =
VAR __MaxDate = MAX([Date])
VAR __Year = YEAR(__MaxDate)
VAR __Table = SUMMARIZE(FILTER('Table', YEAR([Date]) = __Year && [Date] <= __MaxDate),[Month],"__MonthlyAtt",[MONTHLY ATT])
RETURN
AVERAGEX(__Table, [__MonthlyAtt])
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |