Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

How to Associate to the Closest Date

Hi all,

I have two date fields that I need to associate together to the nearest occurrence. We have OrderDate, which is when an order is actually placed, and HistoricalDate, associated to a change in Average Cost for the specific product.

For example:

              ORDER TABLE                                            COST TABLE

OrderID     SkuID          OrderDate                SkuID          HistoryDate            Cost     

    1              123              1/1/2015                 123              12/31/2014              $3.00

    2              123              1/2/2015                 123              1/3/2015                  $3.50

    3              123              1/3/2015                  

In this example, both OrderID's 1 and 2, should be associated with the cost of HistoryDate 12/31/2014, while Order 3 should be associated with the cost of HistoryDate 1/3/2015.

Any suggestions?

1 Solution

Accepted Solutions
ramoncova06
Valued Contributor III

Re: How to Associate to the Closest Date

use intervalmatch

PFA

4 Replies
ramoncova06
Valued Contributor III

Re: How to Associate to the Closest Date

use intervalmatch

PFA

MVP
MVP

Re: How to Associate to the Closest Date

like this?

Not applicable

Re: How to Associate to the Closest Date

Thanks, I wondered if I was going to have to create a range between the two dates!

MVP
MVP

Re: How to Associate to the Closest Date

Hi Andrea,

Have you tested both solutions?

Community Browser