Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
racer25
Contributor III
Contributor III

Join Challenge ( Thinking Interval )

Hi All,

Hope you are well.

Struggling where to start with one

I have this data ( small sample )

INSURER CODEINSURER BRANCHRISK CODEINCOME DATEPREMIUMCOMMISSIONACTUAL RATEDEFAULT RATE
M018100A00101/01/2018100010010%15%
M018100A00101/11/2017200036018%12%

 

And I am trying to populate the DEFAULT RATE from ICA_RATE below.

ICA_INSCODEICA_INSBRANCHICA INS_CODEICA RATEICA DATE
M018100A00115%01/07/2017
M018100A00112%01/10/2017
M018100A00115%31/12/2017

 

There can be many Insurer Codes and Risk Codes. The rate should be selected from Income Date in between the 2 dates or if nothing in between then today.

In my example it picked 15% as it was the last update and 12% as after 01/10/2017 but before the next updated date.

I know as much to think of Interval Match but little beyond that.

If anyone could help me out on this it would be very much appreciated.

Thanks

Rob 

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

You need to create a from - to from your ICA DATE and then you could populate it to a continuous date with an intervalmatch-logic (personally I prefer the use of while-loops because this "manually" way is more flexible). The result could you then join or map to your fact-table. Here a simplified example what is meant:

t0: load * inline [
KEY, %, date
M018, 15%, 01.07.2017
M018, 12%, 01.10.2017
M018, 15%, 31.12.2017
];

t1: mapping load KEY & '|' & date(from + iterno() -1) as KeyDate, % while from + iterno() -1 <= to;
load KEY, date as from, if(KEY = previous(KEY), date(previous(date)-1), today()) as to, %
resident t0 order by KEY, date desc;

drop tables t0;

Important by such an approach is the proper sorting within a resident load.

- Marcus

View solution in original post

3 Replies
racer25
Contributor III
Contributor III
Author

Any help on this would be much appreciated.

marcus_sommer

You need to create a from - to from your ICA DATE and then you could populate it to a continuous date with an intervalmatch-logic (personally I prefer the use of while-loops because this "manually" way is more flexible). The result could you then join or map to your fact-table. Here a simplified example what is meant:

t0: load * inline [
KEY, %, date
M018, 15%, 01.07.2017
M018, 12%, 01.10.2017
M018, 15%, 31.12.2017
];

t1: mapping load KEY & '|' & date(from + iterno() -1) as KeyDate, % while from + iterno() -1 <= to;
load KEY, date as from, if(KEY = previous(KEY), date(previous(date)-1), today()) as to, %
resident t0 order by KEY, date desc;

drop tables t0;

Important by such an approach is the proper sorting within a resident load.

- Marcus

racer25
Contributor III
Contributor III
Author

Many thanks Marcus both for the solution and the knowledge share of why this works. I'll certainly be able to implement.