Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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.
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
Hi @v-stephen-msft and @Greg_Deckler
Finally, I have managed this:
@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])
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
123 | |
78 | |
48 | |
38 | |
37 |
User | Count |
---|---|
196 | |
80 | |
70 | |
51 | |
42 |