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

Running totals between to dates

Hi,

 

I have a fact table with offers:

 

OfferId

Date

CloseDate

Amount

 

I want to have the running totals for all my offers. However, the amount of an offer should only be added between Date and CloseDate. Also I am having a dimension date table which has a relation to the date field of Offer table. Unfortunately, we are not writing offers every day (especially not on saturdays and sundays :-)) so it would be great if I could use the date field of my date table to see the amount of open offers for every day (irrespective of if an offer was created that day or not).

 

I tried many different things but I am not able to figure this out on my own.

 

Any help would be great.

 

Thx Christian

1 ACCEPTED SOLUTION

Hi @_chris_ 

 

Try this measure instead. It doesn't care whether there is a relationship between both tables because it uses ALL to remove all filters in the context before comparing dates. 

Open Amount = 
SUMX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date] <= MAX ( 'Date'[Date] ) && 'Table'[CloseDate] > MAX ( 'Date'[Date] )
    ),
    'Table'[Amount]
) + 0

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

7 REPLIES 7
_chris_
Helper III
Helper III

Hi hnguy71,

 

thanks that you plan on helping me.

 

Here you find a very simplified dataset, however, I hope it becomes more clear what I need.

 

_chris__0-1653147927302.png

 

Again, thank you very much!

 

Hi @_chris_ 

 

Please create the following measure in your model. 

Open Amount = 
CALCULATE (
    SUM ( 'Table'[Amount] ),
    ALL ( 'Table' ),
    'Table'[Date] <= MAX ( 'Date'[Date] ),
    'Table'[CloseDate] > MAX ( 'Date'[Date] )
) + 0

vjingzhang_1-1653471746594.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Thank you very much, unfortunately I am getting an error:

 

_chris__1-1653502187655.png

 

 

_chris__0-1653501906454.png

 A function of type 'MAX' has been used in a TRUE/FALSE expression which serves as a Table filter expression. This is not allowed.

 

One more information here: I am not having a relationship between both tables. Is this correct?

Hi @_chris_ 

 

Try this measure instead. It doesn't care whether there is a relationship between both tables because it uses ALL to remove all filters in the context before comparing dates. 

Open Amount = 
SUMX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Date] <= MAX ( 'Date'[Date] ) && 'Table'[CloseDate] > MAX ( 'Date'[Date] )
    ),
    'Table'[Amount]
) + 0

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Hi jingzhang,

 

now it works perfectly. Thank you very much!

 

The "old" measure I got running with a small file still yesterday evening (not my "big" model). However, I wanted to do something like IF(ISBLANK(Table[CloseDate]), DATE(2100, 12, 31), Table[CloseDate])) as offers which are not having a close date also should be included. This did not work with the first measure. But now also this works perfectly fine.

 

Thx again!

 

Christian

 

 

hnguy71
Super User
Super User

Hi @_chris_ ,

 

Can you supply some sample data and expected output? This seems easy but with some data it would be better to understand your requirements a bit further.



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thanks hnguy71 that you plan on helping me 🙂

OfferIdDateCloseDateAmount
115.03.202218.03.2022100
217.03.202221.03.2022

1000

 

DateOpenAmount
 
14.03.20220
15.03.2022100
16.03.2022100
17.03.20221100
18.03.20221000
19.03.20221000
20.03.20221000
21.03.20220
 

 

This is very simplified my scenario but I hope it becomes clear what I need...

 

Again, thank you very much!

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.