Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

simotrab
Contributor II

For loop and crosstable() ?

Hi community!

Hi have some data whom are in this way:

load*inline

[product, from, to, label, place

a,2015,2016,alfa, x

b,2014,2017,beta, y

]

;

I need a result like this and I suppose I need a crosstable() in a for loop:

product label place  date

a           alfa   x        2015

a           alfa   x        2016

b           beta  y       2014

b           beta  y       2015

b           beta  y       2016

b           beta  y      2017

As you can see the span of the date is variable, so I'm not able to do a proper for loop mixed a crosstable I suppose.

Thanks in advance

1 Solution

Accepted Solutions
MVP
MVP

Re: For loop and crosstable() ?

May be this

Table:

LOAD product,

label,

place,

from + IterNo() - 1 as date

While from + IterNo() - 1 <= to;

LOAD * INLINE [

    product, from, to, label, place

    a, 2015, 2016, alfa, x

    b, 2014, 2017, beta, y

];

4 Replies
MVP
MVP

Re: For loop and crosstable() ?

May be this

Table:

LOAD product,

label,

place,

from + IterNo() - 1 as date

While from + IterNo() - 1 <= to;

LOAD * INLINE [

    product, from, to, label, place

    a, 2015, 2016, alfa, x

    b, 2014, 2017, beta, y

];

OmarBenSalem
Esteemed Contributor

Re: For loop and crosstable() ?

years:

LOAD * INLINE [

YEAR

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

];

f:

load * inline

[

product, from, to, label, place

a,2015,2016,alfa, x

b,2014,2017,beta, y

]

;

Inner Join IntervalMatch ( "YEAR" )

LOAD from, to

Resident f;

DROP fields from,to from f;

drop table years;

result:

Capture.PNG

OmarBenSalem
Esteemed Contributor

Re: For loop and crosstable() ?

Brilliant as usual !

simotrab
Contributor II

Re: For loop and crosstable() ?

Great, thank you very much!

Community Browser