Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Pedro_Rodriguez
Contributor III
Contributor III

IntervalMatch including field in fact table

Hello,

Having the following data:

Classes:

LOAD * INLINE [

    Class, BeginAge, EndAge

    18-25, 18, 25

    26-35, 26, 35

    36-45, 36, 45

    46-65, 46, 65

];

Customers:

LOAD * INLINE [

    ID, Name, Age, Accident

    1, Jan, 18, 1

    2, Klaas, 22, 0

    3, Kjeld, 46, 0

    4, Jochem, 35, 1

    5, Robin, 34, 0

    6, Jeroen, 29, 1

    7, Henk, 50, 1

    8, Piet, 55, 1

    9, Bram, 60, 1

];

With this code I assign age range to each person:

Inner JOIN (Classes)

IntervalMatch (Age)

Load Distinct

  BeginAge,

  EndAge

Resident Classes;

But what I want to achieve is only ONE table containing:

Customers_Def:

    ID, Name, Age, Accident, Class

    1, Jan, 18, 1, 18-25

    2, Klaas, 22, 0, 18-25

    3, Kjeld, 46, 0, 46-65

    4, Jochem, 35, 1, 26-35

    5, Robin, 34, 0, 26-35

    6, Jeroen, 29, 1, 26-35

    7, Henk, 50, 1, 46-65

    8, Piet, 55, 1, 46-65

    9, Bram, 60, 1, 46-65

*In my data there's no chance of one person in two age classes

Thanks a lot in advance!

1 Solution

Accepted Solutions
balar025
Creator III
Creator III

Hi ,

You can use below code.

Inner JOIN (Classes)

IntervalMatch (Age)

Load Distinct

  BeginAge,

  EndAge

Resident Classes;

join

Load *

Resident Classes;

Drop table Classes;

Drop field  BeginAge,  EndAge;

Regards,

Ravi Balar

View solution in original post

3 Replies
balar025
Creator III
Creator III

Hi ,

You can use below code.

Inner JOIN (Classes)

IntervalMatch (Age)

Load Distinct

  BeginAge,

  EndAge

Resident Classes;

join

Load *

Resident Classes;

Drop table Classes;

Drop field  BeginAge,  EndAge;

Regards,

Ravi Balar

effinty2112
Master
Master

Hi Pedro,

                    Add this to the script:

Left Join(Customers)

LOAD Age, Class Resident Classes;

DROP Table Classes;

cheers

Andrew

Pedro_Rodriguez
Contributor III
Contributor III
Author

Thank you both guys, really appreciate it