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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Pulling Value from Another Table based on Two Date Fields

Hi,

I have two tables as part of a data model - one called 'pbi TablePriceDiscStaging' and another called 'SalesOrderLineV2Staging'.  These two tables are linked via a field called 'AccountItemUnit.'

garynorcross_0-1593538185894.png

On the pbi TablePriceDiscStaging table, there are fields for FROMDATE and TODATE.  These fields represent the active time that a Pricing Agreement is valid.  I need to pull the 'AMOUNT' field from the pbi TablePriceDiscStaging table when the ORDERCREATIONDATETIME field (formatted as date) from the SalesOrderLineV2Staging table falls within the dates between FROMDATE and TODATE fields.  Is this possible?  If so, is there DAX that will work to accomplish this?  


I have already attempted making the transformation in the Query Editor to make a list of dates between the FROMDATE/TODATE fields, and the program crashes each time.

Thanks in advance!

1 ACCEPTED SOLUTION
DataZoe
Microsoft Employee
Microsoft Employee

@Anonymous 

 

You could try this measure:

 

Amount in Pricing Agreement Dates =
CALCULATE (
    SUM('pbi TablePriceDiscStaging'[Amount]),
    FILTER (
        'pbi TablePriceDiscStaging',
        'pbi TablePriceDiscStaging'[FROMDATE] <= MIN ( SalesOrderLineV2Staging[ORDERCREATIONDATETIME] )
            && 'pbi TablePriceDiscStaging'[TODATE] > MAX ( SalesOrderLineV2Staging[ORDERCREATIONDATETIME] )
    )
)

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

2 REPLIES 2
DataZoe
Microsoft Employee
Microsoft Employee

@Anonymous 

 

You could try this measure:

 

Amount in Pricing Agreement Dates =
CALCULATE (
    SUM('pbi TablePriceDiscStaging'[Amount]),
    FILTER (
        'pbi TablePriceDiscStaging',
        'pbi TablePriceDiscStaging'[FROMDATE] <= MIN ( SalesOrderLineV2Staging[ORDERCREATIONDATETIME] )
            && 'pbi TablePriceDiscStaging'[TODATE] > MAX ( SalesOrderLineV2Staging[ORDERCREATIONDATETIME] )
    )
)

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Anonymous
Not applicable

@DataZoe , thank you so much, this worked!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors