Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
PARK_JY
Contributor III
Contributor III

IF, MAX in script.

Hi,

I'm using QLIK SENSE, but I'm having some difficulties, so please help.


data:
load * inline[
region_number, population
aaa/111, 988
aaa/222, 654
aaa/333, 651
bbb/111, 241
bbb/222, 755
bbb/333, 123
];

I want to add a new field to display the regions
with the most population in the same region.
The answer I want is below.

region_number, population, max
aaa/111, 988, v
aaa/222, 654
aaa/333, 651
bbb/111, 241
bbb/222, 755, v
bbb/333, 123

if ~ blahblah ~ 'v' as max,

Please let me know how to solve it. 

Thank you.

Labels (1)
1 Reply
MayilVahanan

Hi 

Try like below

data:
load *, SubField(region_number, '/',1) as region inline[
region_number, population
aaa/111, 988
aaa/222, 654
aaa/333, 651
bbb/111, 241
bbb/222, 755
bbb/333, 123
];

join
Load region, max(population) as Max Resident data Group by region;

Final:
LOAD region_number, population, if(Max = population, 'v') as Max Resident data;

DROP Table data;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.