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
ssvr
Helper III
Helper III

Cumulative sum of a column

Hi,

 

I want to create a new column (Cumulative sales)

 

any one provide the DAX for new column

 

Thanks

1 ACCEPTED SOLUTION
quentin_vigne
Solution Sage
Solution Sage

Hi @ssvr

 

Here is a nice formula for cumulative column 

 

Cumulative sales =
CALCULATE (
    SUM ( 'YourTable'[Sales] ),
    ALL ( 'YourTable)' ),
    'YourTable'[Date] <= EARLIER ( 'YourTable'[Date] )
)

- Quentin

View solution in original post

13 REPLIES 13
Caldowd98
Helper I
Helper I

Hi i've been using this formula and it works great. However when i use slicers that are not related to the date, it will not update the quantities. Any ideas ?

 

Thanks!

quentin_vigne
Solution Sage
Solution Sage

Hi @ssvr

 

Here is a nice formula for cumulative column 

 

Cumulative sales =
CALCULATE (
    SUM ( 'YourTable'[Sales] ),
    ALL ( 'YourTable)' ),
    'YourTable'[Date] <= EARLIER ( 'YourTable'[Date] )
)

- Quentin

Hi i've been using this formula and it works great. However when i use slicers that are not related to the date, it will not update the quantities. Any ideas ?

 

Thanks!

If there are 2 Rows for same date it is showing double value for that row. Am I doing any thing wrong

@pnvinod

 

What does your date column looks like ? 

 

dd/mm/yyyy hh mm ss or only dd/mm/yyyy ?

 

This formula work for distinct rows, on a distinc index value.

 

- Quentin

Hi,

 Thanks. I am using "dd/mm/yyyy" 

@pnvinod

 

So if you have a lot of sales each day and a row for each sales it won't work.


The solution will be to :

 

Either have a Index column (like Sale1; Sale2 that identify each sale)

OR

Create a new table that use : Table = Summarize(YourTable;YourTable[Date];"Sales";SUM(YourTable[Sales]))

It will display the sum of your sales for each day. And when you will have this table you will be able to create a cumulative column with this table.

 

- Quentin

Anonymous
Not applicable

If I created an index column for each unique sale how then do I include the index into the DAX formula?

@quentin_vigne

        Thanks. It is working correctly now

For your query this is the solution DAX

 

Actuals Budget = CALCULATE(
SUM('Gross FCC'[Actuals]),
FILTER(ALLSELECTED('Gross FCC'),
'Gross FCC'[Posting period (r)]<=MAX('Gross FCC'[Posting period (r)])
))

@ssvr Thank you so much for your solution. I was stuck at the same problem. I was using ALL so getting incorrect values then I replaced it with ALLSELECTED so Instantly I got the expected result.

 

Thanks a bunch buddy for your solution!

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Thanks it works fine.

 

CALCULATE (
    SUM ( 'dummy sales'[Sales]),
    ALL('dummy sales'),
    'dummy sales'[Date] <= EARLIER ( 'dummy sales'[Date])
)

@ssvr

 

You're welcome

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