Forum Discussion

frankhofmans's avatar
frankhofmans
Helper IV
4 years ago
Solved

Search value between two dates

hi PBI experts,

 

i have 2 tables (with >100k rows)

 

table 1: orders per provider

 

Client IDOrder dateOrder nr.
00101-03-2022111
00102-04-2022112
00210-04-2022113
00313-04-2022114
00420-04-2022115
00403-05-2022116
00427-05-2022117
00502-06-2022118

 

table 2: provider overview

 

StartEndClient IDPurchase price
01-01-202201-01-999900120
01-01-202201-03-202200225
01-03-202201-01-999900227
01-01-202201-01-999900325.5
01-01-202201-04-202200425.7
01-04-202201-05-202200426
01-05-202201-01-999900426.3
01-01-202201-01-999900525.8

 

if i want to have the purchase price for provider 004 on 20-04-2022, it has to be 26 (the price between 01-04-2022 and 01-05-2022). So i want to have the following results:

 

Client IDOrder dateOrder nr.Purchase price
00101-03-202211120
00102-04-202211220
00210-04-202211327
00313-04-202211425.5
00420-04-202211526
00403-05-202211626.3
00427-05-202211726.3
00502-06-202211825.8

 

Does anyone have a solution for this?

 

Thanks in advance,

 

Regards,

 

Frank

  • Hey Frank,

    try something like this:

    I created a dimension table for the customer as is good practice and create a measure as so:

     

    If this post solves your problem, accept it as a solution
    Appreciate your kudos

     

1 Reply

  • Hey Frank,

    try something like this:

    I created a dimension table for the customer as is good practice and create a measure as so:

     

    If this post solves your problem, accept it as a solution
    Appreciate your kudos