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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NikkiG12
Frequent Visitor

Budget + Actual Totals Not Summing Right

I have three data tables: Budget, YTD, Calendar. I've made a relationship between budget and calendar by year, and same relationship from calendar and YTD by year. 

I want to create a column chart where each month is summed and it changes based on a year splicer. 

I've tried many different ways but I can't seem to get the months to sum with their respective amounts, each month just gives me the annual total. Here's my last dax, its the same for YTD"

 

Total_Budget = CALCULATE(SUM('Budget'[Budget]), ALLEXCEPT('CalendarTable', 'CalendarTable'[Year], CalendarTable[Month_Name]))

What am I doing wrong?

1 ACCEPTED SOLUTION
v-yilong-msft
Community Support
Community Support

Hi @NikkiG12 ,

I create a table as you mentioned.

vyilongmsft_0-1710924458231.png

vyilongmsft_1-1710924582771.png

It seems like the issue might be with the ALLEXCEPT function in your DAX formula. ALLEXCEPT retains all filters for the specified columns, but it removes filters from all other columns in the table. If you are getting the annual total for each month, it’s likely because the filter on the months is being removed, and thus the calculation is summing over the entire year.

I think you can use FILTER function to keep the context of the current month when calculating the total. 

Here is the adjusted DAX code.

 

 

Total_Budget = 
CALCULATE(
    SUM('Budget'[Budget]), 
    FILTER(
        ALL('CalendarTable'[Month_Name]), 
        'CalendarTable'[Month_Name] = MAX('CalendarTable'[Year])
    )
)

 

vyilongmsft_2-1710924678565.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yilong-msft
Community Support
Community Support

Hi @NikkiG12 ,

I create a table as you mentioned.

vyilongmsft_0-1710924458231.png

vyilongmsft_1-1710924582771.png

It seems like the issue might be with the ALLEXCEPT function in your DAX formula. ALLEXCEPT retains all filters for the specified columns, but it removes filters from all other columns in the table. If you are getting the annual total for each month, it’s likely because the filter on the months is being removed, and thus the calculation is summing over the entire year.

I think you can use FILTER function to keep the context of the current month when calculating the total. 

Here is the adjusted DAX code.

 

 

Total_Budget = 
CALCULATE(
    SUM('Budget'[Budget]), 
    FILTER(
        ALL('CalendarTable'[Month_Name]), 
        'CalendarTable'[Month_Name] = MAX('CalendarTable'[Year])
    )
)

 

vyilongmsft_2-1710924678565.png

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors