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
Dunner2020
Post Prodigy
Post Prodigy

Cumulative sum by month does not produce the right result

Hi there,

 

I have a data which is as shown in the figure:

 

leo_89_0-1606262631822.png

 

I have a measure which calculates a value let say TotalCustomerDuration which can be calculated using the following measure:

 

TotalCustomerDuration = Sumx(Table, [NumberofConsumers]*[Duration])/91577

 

I want to calculate the Cumulative Sum of the TotalCustomerDuration by month.  I wrote the cumulative sum as follow:

 

Cumulative Sum = 

var CurrentDate = MAX('Table'[Date])
Return
sumx( filter(ALL('Table'),'Table'[Date]<=CurrentDate ), [TotalCustomerDuration ])
 
This measure produces the following output:
Screenshot 2020-11-25 131942.jpg
 

As you can see the cumulative sum is not producing the right result. I am not sure where am I making the mistake. Any help would be appreciated. Data can be download from here https://1drv.ms/u/s!AucycxZHFe9TjVP95dR9t35xwz0k?e=ALfxOk 

 

 

 

 

 

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

Hi @Dunner2020 

Please check the type of your date column, you can build a rank column to have a test.

Rank column:

Rank = RANKX('Table','Table'[Date],,ASC,Dense)

I use your measure to have a test, and it works well.

Result is as below.

1.png

You can download the pbix file from this link: Cumulative sum by month does not produce the right result

 

Best Regards,

Rico 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

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @Dunner2020 

Please check the type of your date column, you can build a rank column to have a test.

Rank column:

Rank = RANKX('Table','Table'[Date],,ASC,Dense)

I use your measure to have a test, and it works well.

Result is as below.

1.png

You can download the pbix file from this link: Cumulative sum by month does not produce the right result

 

Best Regards,

Rico Zhou

 

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

 

Dunner2020
Post Prodigy
Post Prodigy

@amitchandak , I tried the 

Cumulative Sum =
calculate( [TotalCustomerDuration],filter(ALL('Table'),'Table'[Date]<=MAX('Table'[Date]) ))

 

But still, it gave the same result.

amitchandak
Super User
Super User

@Dunner2020 , Formula seems fine at first look.

Try like

Cumulative Sum =
calculate( [TotalCustomerDuration],filter(ALL('Table'),'Table'[Date]<=MAX('Table'[Date]) ))

Cumulative Sum =
calculate( sum(Table[TotalCustomerDuration]),filter(ALL('Table'),'Table'[Date]<=MAX('Table'[Date]) ))

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.