Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
DHR
Frequent Visitor

Calculating monthly values from yearly values

I have a table with YTD values and I am trying to calculate the monthly values form the YTD values. I am able to get the correct monthly value for all dates but my total is incorrect. I have searched the forum and can see that an incorrect total is a common problem but I cannot figure out how to get the correct total. I have tried variants with SUMX and SUMMARIZE (which I have found in other answers) but as I am fairly new to DAX I probably don't understand these functions well enough to figure out how to do this correctly.

 

Here is the output I get

DateMeasure
2021-05-31-213,188
2021-06-30213,188
2021-07-31

-42,638

2021-08-310
2021-09-3042,638
2021-12-31

1,492,753

Total1,194,289

 

As you can see the total I get is 1,194,289 instead of the expected total of 1,492,753.

 

Here is a link to a test file for convenience

https://drive.google.com/file/d/19zNfapTc7tyF2nppHVV5bJEI3TOXvsbV

 

Any help would be greatly appreciated!

5 REPLIES 5
DHR
Frequent Visitor

Thanks for the reply @lbendlin 

 

The source only provides me with the YTD amount for each year and month. The date in the data table is a calculated column. Therefore I will only ever have dates for the end of the month and that is why I chose (possibly incorrectly) to have a date table only for the end of the month. I first tried with a complete date table but ran into trouble with the all values in the middle of the month but maybe there is a way around that that I'm missing?

 

Asuming I want the total for the whole year I could use AmountYTD as you suggested but that won't work if I want the total for monthly values of July to December as an example.

 

Any ideas as to how I can accomplish calculating the monthly amount and get a correct total? 

Here is the calculation for the monthly amount

 

lbendlin_0-1708559379574.png

 

You already have the correct total, it is your Dec 2021 YTD amount.  There is no need to compute that again.

 

 

DHR
Frequent Visitor

Thank you for taking the time to reply to me @lbendlin 

 

I apologize for not having explained my problem in more detail with examples from the beginning. As I wrote in my original question I do have the desired monthly values, it is only the totalt that I can't seem to get correct.

 

A missing row in my source data indicates that the AmountYTD value is zero meaning that the monthly value for that month shoulde be the negative value from previous months AmountYTD (unless the month is January then it should be equal to AmountYTD in January as I am working with the calendar year).

 

Here is my desired output:

YearMonthAmountYTDMonthly value
20206-40 000-40 000
20207-40 0000
20208-40 0000
20209-40 0000
202010-40 0000
202011-40 0000
202012-14 957 500-14 917 500
20211 0
20212 0
20213 0
20214 0
20215-213 188-213 188
20216 213 188
20217-42 638-42 638
20218-42 6380
20219 42 638
202110 0
202111 0
2021121 492 7531 492 753
Total  -13 464 747

 

Let say I want to filter on the period from June to December 2021 then I want the total to be the sum of the monthly values for the selected months.

YearMonthAmountYTDMonthly value
20216 213 188
20217-42 638-42 638
20218-42 6380
20219 42 638
202110 0
202111 0
2021121 492 7531 492 753
Total  1 705 941

 

by filtering periods you are robbing yourself of the baseline. You wouldn't be able to do anything for the months before the first transaction in the filter context.

 

I would suggest refactoring the data source so it provides actuals rather than  accumulations.

lbendlin
Super User
Super User

Your calendar table is incomplete.  Needs to be contiguous and covering.

 

You already have the AmountYTD  (for whatever reason), so might as well use it for the total, even if it makes little sense .

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.