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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
TKBI
Frequent Visitor

Accumulate Column

Hello, 

 

I have a list of contracts and am trying to figure out a way to accumulate the sum of active contracts over the year. 

 

My Datatable looks something like this: 

Counter StartDate Enddate
1 01.01.2024 31.12.2028
1 01.01.2024 31.12.2026
1 01.01.2024 01.08.2026
1 01.01.2023 01.02.2024
1 01.01.2002 01.03.2024
1 01.01.2004 01.06.2024
1 01.03.2024 01.08.2026
1 01.03.2024 01.08.2026
1 01.06.2024 01.08.2026
1 01.02.2024 01.08.2026
1 02.02.2024 01.08.2026
1 03.02.2024 01.08.2026
1 04.03.2024 01.08.2026
1 05.05.2024 01.08.2026
1 06.06.2024 01.08.2026
1 07.07.2024 01.08.2026
1 01.01.2013 01.02.2024
1 01.01.2012 01.08.2024
1 01.01.2015 01.09.2024
1 01.01.2016 01.03.2024

Now its no problem to calculate the to number of active contracts for any given month, but I cant figure out a way to accumulate them over the year. My goal would be a table that looks like this for the current example: 

 

Date Counter Accumulated
01.01.2024 10 10
01.02.2024 11 21
01.03.2024 13 34
01.04.2024 12 46
01.05.2024 12 58
01.06.2024 14 72
01.07.2024 14 86
01.08.2024 15 101
01.09.2024 14 115
01.10.2024 13 128
01.11.2024 13 141
01.12.2024 13 154

 

I could not find an example for this specific Problem on the Forums and all solutions I found are not quite working for this situation. 

 

Any help or ideas would be greatly appreciated. 

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

For calculating running totals I recommend cheking this article: Computing running totals in DAX - SQLBI

For your case here is an example:

Column =
VAR MaxDate = [Date] -- Saves the last visible date
RETURN
    CALCULATE (
        SUM('Table (39)'[Counter]),            -- Computes sales amount
        'Table (39)'[Date] <= MaxDate,   -- Where date is before the last visible date
        ALL ( 'Table (39)')               -- Removes any other filters from Date
    )


This is for a column like you requested, but I recommend using a measure. Also I recommend adding calendar table to your model. 


End result:

ValtteriN_0-1719997359542.png


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ValtteriN
Super User
Super User

Hi,

For calculating running totals I recommend cheking this article: Computing running totals in DAX - SQLBI

For your case here is an example:

Column =
VAR MaxDate = [Date] -- Saves the last visible date
RETURN
    CALCULATE (
        SUM('Table (39)'[Counter]),            -- Computes sales amount
        'Table (39)'[Date] <= MaxDate,   -- Where date is before the last visible date
        ALL ( 'Table (39)')               -- Removes any other filters from Date
    )


This is for a column like you requested, but I recommend using a measure. Also I recommend adding calendar table to your model. 


End result:

ValtteriN_0-1719997359542.png


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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