Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
didierodayo
Partner - Creator III
Partner - Creator III

Flag Max Value

Hello,

I have this Load script and am trying to flag the max and min within the load script.

Anyone with an idea of what the best method will be to achieve the required result

load * inline [

Type, Month, Amount

A,1,6

A,1,8

B,2,4

B,2,3

C,3,7

C,3,5

D,4,9

D,4,3

E,5,10

E,5,4

F,6,9

F,6,2

G,7,5

G,7,6

];

Expected result

    

TypeMonthAmountRank
A160
A181
B230
B241
C350
C371
D430
D491
E540
E5101
F620
F691
G750
G761

Thanks

1 Solution

Accepted Solutions
Sergey_Shuklin
Specialist
Specialist

Hello, Didier!

temp:

load * inline [

Type, Month, Amount

A,1,6

A,1,8

B,2,4

B,2,3

C,3,7

C,3,5

D,4,9

D,4,3

E,5,10

E,5,4

F,6,9

F,6,2

G,7,5

G,7,6

];

left join (temp)

load Type,Month, max(Amount) as Amount, 1 as Rank resident temp group by Type,Month;


//this can be omitted

NoConcatenate

result:

Load Type, Month, Amount, if(isnull(Rank),0,1) as Rank resident temp;


DROP TABLE temp;

View solution in original post

3 Replies
Sergey_Shuklin
Specialist
Specialist

Hello, Didier!

temp:

load * inline [

Type, Month, Amount

A,1,6

A,1,8

B,2,4

B,2,3

C,3,7

C,3,5

D,4,9

D,4,3

E,5,10

E,5,4

F,6,9

F,6,2

G,7,5

G,7,6

];

left join (temp)

load Type,Month, max(Amount) as Amount, 1 as Rank resident temp group by Type,Month;


//this can be omitted

NoConcatenate

result:

Load Type, Month, Amount, if(isnull(Rank),0,1) as Rank resident temp;


DROP TABLE temp;

Kushal_Chawda

Data:

load * inline [

Type, Month, Amount

A,1,6

A,1,8

B,2,4

B,2,3

C,3,7

C,3,5

D,4,9

D,4,3

E,5,10

E,5,4

F,6,9

F,6,2

G,7,5

G,7,6

];

New:

LOAD *,

     if(Type<>Previous(Type),0,1) as Rank

Resident Data

order by Type, Month, Amount;

DROP Table Data;

balabhaskarqlik

WebData:

LOAD Type,

     Month,

     Amount

FROM

[https://community.qlik.com/thread/265033]

(html, codepage is 1252, embedded labels, table is @1);

New:

LOAD *,

    If((Type <> Previous(Type)),0,1) as Rank

Resident WebData Order by Type;

   

DROP Table WebData;