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
Eiji77
Helper II
Helper II

I want to calculate the cumulative total.

無題.png

I want to calculate the cumulative total.

1 ACCEPTED SOLUTION

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

15 REPLIES 15
v-danhe-msft
Employee
Employee

Hi @Eiji77,

Which formula do you want to calculate the cumulative total with, a calculated column or a measure?

If the former, you could refer to this formula:

Column = CALCULATE(SUM(Table1[Sales]),FILTER('Table1','Table1'[Customer]<=EARLIER(Table1[Customer])))

Result:

1.PNG

If the latter, you could refer to this formula:

Measure = CALCULATE(SUM(Table1[Sales]),FILTER(ALL(Table1),'Table1'[Customer]<=MAX('Table1'[Customer])))

Result:

2.PNG

You could also downlaod the pbix file to have a view.

https://www.dropbox.com/s/mu8hkb236ypwsa6/I%20want%20to%20calculate%20the%20cumulative%20total..pbix...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,Daniel. It seems that the way you taught is cumulative order by Customer name. Can you do it in descending order of sales amount?

 

無題.png

Hi,

 

This should be possible to solve without creating an index column.  Please share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

https://www.dropbox.com/s/eb63y9gxcefvvaq/I%20want%20to%20calculate%20the%20cumulative%20total..pbix...

 

Thank you. I want to calculate the cumulative total in the customer group. It is not a customer name.

Hi @Eiji77,

Based on my test, you could add index column to calculate the total running:

Sample data:

1.PNG

Add index coulumn in query editor:

2.PNG

Create calculated column or measure:

Calculated column:

Column = CALCULATE(SUM(Table1[Sales]),FILTER(Table1,'Table1'[Index]<=EARLIER('Table1'[Index])))

Measure:

Measure = CALCULATE(SUM(Table1[Sales]),FILTER(ALL(Table1),'Table1'[Index]<=MAX('Table1'[Index])))

Result:

1.PNG2.PNG

Regards,

Danilel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Sorry, I want to calculate the cumulative total in the customer group. It is not a customer name.

Then,I can not index it.

 

https://www.dropbox.com/s/eb63y9gxcefvvaq/I%20want%20to%20calculate%20the%20cumulative%20total..pbix...

You can add a filter statement that checks for equality within the group. But then to get the correct grand total, you need to add another condition:

 

Measure =
IF (
    ISFILTERED ( 'Customer Group'[Customer Group] ),
    CALCULATE (
        SUM ( Sales[Sales amount] ),
        FILTER (
            ALL ( 'Customer Group' ),
            'Customer Group'[Customer Name] <= MAX ( Sales[Customer Name] )
                && 'Customer Group'[Customer Group] = MAX ( 'Customer Group'[Customer Group] )
        )
    ),
    CALCULATE (
        SUM ( Sales[Sales amount] ),
        FILTER (
            ALL ( 'Customer Group' ),
            'Customer Group'[Customer Name] <= MAX ( Sales[Customer Name] )
        )
    )
)

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

My measure creates a cumulative total over your customers within their customer groups:

 

image.png

 

If this is not what you want, please specify exactly what you need by posting a (picture) of the desired table.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Sorry , I want to this result .スクリーンショット 2018-09-03 15.22.35.png

 

This would be it then:

Measure = 
    CALCULATE (
        SUM ( Sales[Sales amount] ),
        FILTER (
            ALL ( 'Customer Group' ),
            'Customer Group'[Customer Group] <= MAX ( 'Customer Group'[Customer Group] )
        )
    )

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

I tried, the result is this.無題.pngThis is different from what I want to do.

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Eiji77,

If you could not index it, you could use this measure:

Measure = CALCULATE(SUM(Table1[Sales]),FILTER(ALL(Table1),'Table1'[Sales]>=MIN('Table1'[Sales])))

Result:

1.PNG

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I try Measure in Customer Group , but This resulted in such a result.スクリーンショット 2018-09-03 15.19.21.png

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.