Slowly Changing Dimensions and IntervalMatch

    Hi,

     

    I had a challenge where a fact table had Week Number and Value. I also had a lookup table which ranked and grouped the value differently depending on what week you were on.

     

     

    Data:

    Load * Inline [
    Week ,Value
    10 ,1
    10 ,2
    10 ,3
    10 ,4
    10 ,5
    10 ,6
    11 ,1
    11 ,2
    11 ,3
    11 ,4
    11 ,5
    11 ,6
    11 ,7
    ]
    ;

     

     

    Reference:

    Load * Inline [
    Week ,Start ,End ,Rank ,Desc
    10 ,0 ,2 ,1 ,0-2
    10 ,2 ,3 ,2 ,2-3
    10 ,3 ,6 ,3 ,3-6
    10 ,6 ,8 ,4 ,6-8
    11 ,0 ,3 ,1 ,0-3
    11 ,3 ,4 ,2 ,3-4
    11 ,4 ,7 ,3 ,4-7
    11 ,7 ,8 ,4 ,7-8
    ]
    ;

     

     

    Ideally the Rank and Desc would be joined to the main fact table and would look like this:

    Interval.jpg

     

    Solved using the attached code;

     

    Enjoy

     

    Richard

    QlikCentral.Com