Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

aieland1
New Contributor

Minimum among previous

Hi!

I really need your help

For examle I have a table:

[Letter, Number, date
aaa,5,9

bbb,4,9
aaa,7,10

bbb,3,10
aaa,1,12

bbb,3,12
aaa,6,13]

For each letter I need to get a minimum among previous days

So it would be:

[Letter, Number, date, Min
aaa,5,9, -

bbb,4,9, -
aaa,7,10, 5

bbb,3,10, 4
aaa,1,12, 5

bbb,3,12, 3
aaa,6,13, 1]

How can I do that?

Thanks in advance

1 Solution

Accepted Solutions

Re: Minimum among previous

May be this

Table:

LOAD * INLINE [

    Letter, Number, date

    aaa, 5, 9

    bbb, 4, 9

    aaa, 7, 10

    bbb, 3, 10

    aaa, 1, 12

    bbb, 3, 12

    aaa, 6, 13

];

FinalTable:

LOAD *,

If(Letter = Previous(Letter), RangeMin(Peek('Min'), PeekedNumber)) as Min;

LOAD *,

If(Letter = Previous(Letter), Peek('Number')) as PeekedNumber

Resident Table

Order By Letter, date;

DROP Table Table;

DROP Field PeekedNumber;


Capture.PNG


3 Replies
shraddha_g
Honored Contributor III

Re: Minimum among previous

What is the logic behind calculating Min?

Re: Minimum among previous

May be this

Table:

LOAD * INLINE [

    Letter, Number, date

    aaa, 5, 9

    bbb, 4, 9

    aaa, 7, 10

    bbb, 3, 10

    aaa, 1, 12

    bbb, 3, 12

    aaa, 6, 13

];

FinalTable:

LOAD *,

If(Letter = Previous(Letter), RangeMin(Peek('Min'), PeekedNumber)) as Min;

LOAD *,

If(Letter = Previous(Letter), Peek('Number')) as PeekedNumber

Resident Table

Order By Letter, date;

DROP Table Table;

DROP Field PeekedNumber;


Capture.PNG


aieland1
New Contributor

Re: Minimum among previous

It works!

Thank you!

Community Browser