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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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