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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Novice100
Frequent Visitor

Cumulative Sum of a column with blanks and negatives

Hello Community,

 

I need help in writing a DAX to calculate cumulative sum of a cloumn that includes blanks and negatives. I tried with solutions provided in the community but I get the total value in each and every row. Below is the show data and the result which I desire, where the first column is of format Date/Time: 

 

cumsum.PNG

 

Thank you in advance,

Saurav

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Novice100 ,

Please refer to my pbix file to see if it helps you.

Insert an index column.

Then create  a measure.

Measure =
CALCULATE (
    SUM ( 'Table'[C] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Index] <= SELECTEDVALUE ( 'Table'[Index] )
            && 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] )
    )
)

Or a column.

column =
CALCULATE (
    SUM ( 'Table'[C] ),
    FILTER (
        'Table',
        'Table'[Index] <= EARLIER ( 'Table'[Index] )
            && 'Table'[ID] = EARLIER ( 'Table'[ID] )
    )
)

vpollymsft_0-1649829373459.png

 

If I have misunderstood your meaning, please provide your desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @Novice100 ,

Please refer to my pbix file to see if it helps you.

Insert an index column.

Then create  a measure.

Measure =
CALCULATE (
    SUM ( 'Table'[C] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Index] <= SELECTEDVALUE ( 'Table'[Index] )
            && 'Table'[ID] = SELECTEDVALUE ( 'Table'[ID] )
    )
)

Or a column.

column =
CALCULATE (
    SUM ( 'Table'[C] ),
    FILTER (
        'Table',
        'Table'[Index] <= EARLIER ( 'Table'[Index] )
            && 'Table'[ID] = EARLIER ( 'Table'[ID] )
    )
)

vpollymsft_0-1649829373459.png

 

If I have misunderstood your meaning, please provide your desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

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

@Anonymous Hi, 

Thank you! It works perfectly fine.

I tried before by adding new index column but had issues with my data but after the refresh it works. 

Regards

@Novice100

Jihwan_Kim
Super User
Super User

Hi,

I am not sure whether I missed something from your question, but may I ask how you define the sequence between A2 and A3, for instance, which one comes first? 

I think, if you can bring in the "Second" information into the column, it should work. If you cannot, then I suggest having a index column additionally that shows the order of each occurence.

Thank you.


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hello, 

 

Thanks! for the reply.

There is a slight increment in time in seconds and miliseconds between A2 and A3.

For ex: A2 = 10/17/2021 12:36:45

A3 = 10/17/2021 12:36:46. and so on

I also tried with index column but had same issue of repeating total in each rows.

Hi,

I think you have "Second" information to differenciate the order. 

However, I am not sure your power bi data model brought the differeciating factor into the model.

Share your sample pbix file, and then I can try to look into it to come up with more accurate solution.

Thanks.


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hello Sir, I am sorry but due to confidentiality issue I cannot share my pbix file. But I have an extra ID column however, I am not sure if it can help to differentiate the order. Something as below:

 

sum.PNG

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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