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

Date Spread Measure

Hello all,

 

My goal is to have a measure that sums payment amounts based on the spread of two dates, across two different tables.

Purchase table:

Customer ID

Purchase Date

555

1/1/2022

444

1/1/2022

999

6/6/2021


Payments Table:

Customer ID

Payment Date

Payment Amount

555

1/30/2022

 $        100.00

444

1/10/2022

 $        100.00

999

1/10/2022

 $        100.00

 

The desired output would be if the payment date is no greater than 30 days after the purchase date sum payment amounts.

So the measure in question should spit out "$200" in this example.

I know I could get this working making a calculated column for the date spread, but I'm trying to avoid doing so. 

Any help would be appreciated!

1 ACCEPTED SOLUTION
tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @jcawley ,


I think I got to a solution:

tomfox_0-1645128666885.png

 

I pressumed there is a one to many relationship from purchase to payments. I also reckon that the key to create the connection on is not Customer but maybe Order? Yet, I joined on Customer anyway for the sake of this example 🙂 :

tomfox_1-1645128847764.png

 

Here is the measure I created:

TomsPaymentMeasure = 
CALCULATE ( 
    SUMX ( Table16b, [Payment Amount]),
    FILTER ( Table16b, Table16b[Payment Date] -30 < RELATED ( Table16a[Purchase Date] ) )
)

 

Hope this helps! 🙂

 

/Tom
https://www.tackytech.blog

https://www.instagram.com/tackytechtom



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @jcawley 

 

Try this measure:

Date Spread =
VAR _A =
    ADDCOLUMNS (
        ADDCOLUMNS (
            'Payments Table',
            "Purch", RELATED ( 'Purchase table'[Purchase Date] )
        ),
        "DateDiff", DATEDIFF ( [Purch], [Payment Date], DAY )
    )
VAR _B =
    FILTER ( _A, [DateDiff] < 30 )
RETURN
    SUMX ( _B, [Payment Amount] )

 

output:

VahidDM_0-1645137325166.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @jcawley ,


I think I got to a solution:

tomfox_0-1645128666885.png

 

I pressumed there is a one to many relationship from purchase to payments. I also reckon that the key to create the connection on is not Customer but maybe Order? Yet, I joined on Customer anyway for the sake of this example 🙂 :

tomfox_1-1645128847764.png

 

Here is the measure I created:

TomsPaymentMeasure = 
CALCULATE ( 
    SUMX ( Table16b, [Payment Amount]),
    FILTER ( Table16b, Table16b[Payment Date] -30 < RELATED ( Table16a[Purchase Date] ) )
)

 

Hope this helps! 🙂

 

/Tom
https://www.tackytech.blog

https://www.instagram.com/tackytechtom



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

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.