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

Don'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.

Reply
Syndicate_Admin
Administrator
Administrator

Annual sum of monthly values

Hello, I have a "Compensation" measure calculated based on the monthly cumulative values of two measures ("Exports" and "Imports"). The compensation each month is the value of exports unless it exceeds that of imports, in which case it is limited to the value of such imports. The calculation of the accumulated and the comparison in the month is not a problem. My problem is that I can't add up the monthly compensation values in the annual calculation. Instead of obtaining the sum of the 12 monthly values obtained from the monthly accumulated I obtain a new value of "Compensation", calculated from a comparison of the accumulated in the annual calculation.

If the source was columns, it would create a calculated column with the values of "Compensation" and could add the monthly values without problem, but the origin are measures.

I copy below the results I get. You will see that the sum of the 12 "Compensation" values of 2022 does not add up to 489,707, but should appear close to 395,000.

The measure "Compensation" is defined as Compensation= IF([Cumulative exports] < [Cumulative imports], [Exports], [Imports])

Thanks a lot

3A2A88FB-FF6D-4563-B998-5392426C474D.jpeg

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below.

 

 

Compensation =
SUMX (
    SUMMARIZE ( CalendarTable, CalendarTable[Year], CalendarTable[Monthnamesort] ),
    CALCULATE (
        IF ( [Cumulative exports] < [Cumulative imports], [Exports], [Imports] )
    )
)

 

Or, if all four of them are measures, then also please try something like below.

Compensation =
SUMX (
    SUMMARIZE ( CalendarTable, CalendarTable[Year], CalendarTable[Monthnamesort] ),
    
        IF ( [Cumulative exports] < [Cumulative imports], [Exports], [Imports] )
    
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.