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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BREH95
Regular Visitor

Running total between two dates

Hi ,

 

I have the following structure for my dataset : 

 

1 line per contract  , 

 

-  contract ID 

- Start date

- End Date

- Monthly amount

 

 

I'd like to make a chart where i can see the running total  by month ( calculated between start and end date for each contract ) 

 

I tried to create a table date  ,I linked this table to start and end date , then i disabled theese links.

I tried to do something  like  

 

MeasureTest = if ( ('date'),'date'[date]<= Startdate  && ('date'),'date'[date]<= Enddate , Monthly amount , 0 )
 
 I don't know if I need to generate lines between start date to end date or if i can do it with one formula ... 
 
Thx for your help
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from@lbendlin , please allow me to provide another insight:

Hi, @BREH95 

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1721616304694.png

2.Create calculated table references:

time = 
CALENDAR (
    MIN ( 'Table'[START_DATE] ),
    MAX ( 'Table'[START_DATE] ) + MAX ( 'Table'[duration] ) - 1
)

result =
FILTER (
    CROSSJOIN ( 'time', 'Table' ),
    'time'[Date] >= 'Table'[START_DATE]
        && 'time'[Date] <= 'Table'[START_DATE] + 'Table'[duration]
)

3.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1721616440756.png

 

 

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

5 REPLIES 5
lbendlin
Super User
Super User

Assuming your Monthly Amount is due regardless of when in the month the start and end dates are you can use DATEDIFF. But you need to leave your calendar table disconnected.

 

lbendlin_0-1720740192212.png

 

 

 

Hello @lbendlin ,

 

Thanks for your answer 🙂 

 

Your solution works perfectly if i select 1 contract but  doesn't work if multiple selected .. 

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Here are my data , 

 

I need to calculate  the end date  ( I use dateadd , with duration in month ) 

 

 

data.PNG

 

 

then i'd like to generate this data structure for each contract 

 

data 2.PNG

 

 

 

 

and the resultat should look like   this

 

result.png

 

 

Anonymous
Not applicable

Thanks for the reply from@lbendlin , please allow me to provide another insight:

Hi, @BREH95 

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1721616304694.png

2.Create calculated table references:

time = 
CALENDAR (
    MIN ( 'Table'[START_DATE] ),
    MAX ( 'Table'[START_DATE] ) + MAX ( 'Table'[duration] ) - 1
)

result =
FILTER (
    CROSSJOIN ( 'time', 'Table' ),
    'time'[Date] >= 'Table'[START_DATE]
        && 'time'[Date] <= 'Table'[START_DATE] + 'Table'[duration]
)

3.Here's my final result, which I hope meets your requirements.

vlinyulumsft_1-1721616440756.png

 

 

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.