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: 
Anonymous
Not applicable

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
sunny_talwar

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


View solution in original post

3 Replies
shraddha_g
Partner - Master III
Partner - Master III

What is the logic behind calculating Min?

sunny_talwar

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


Anonymous
Not applicable
Author

It works!

Thank you!