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

Flag for max values in load

Hi Experts,

I have this table called Items:

KeyItem DateMain
AAA-1231/1/2018
AAA-1236/1/2020Y
AAA-1235/1/2019Y
AAA-1235/1/2019
BBB-5551/1/2017
BBB-5551/1/2017Y
BBB-5555/1/2018Y
BBB-5553/1/2020

Trying to add a new field, [Max Main], like so:

KeyItem DateMainMax Main
AAA-1231/1/2018
AAA-1236/1/2020YY
AAA-1235/1/2019Y
AAA-1235/1/2019
BBB-5551/1/2017
BBB-5551/1/2017Y
BBB-5555/1/2018YY
BBB-5553/1/2020

Logic for Max Main=Y is basically:

Main = 'Y'

Date = Max(Item Date)

For each Key

Was trying to add this to the load script -

Left Join(Items)

Load

     [Key],

     'Y' as [Max Main]

Resident Items where [Item Date]=Max([Item Date]) and [Main]='Y'

Group by [Key];

But definitely wrong as getting an error in the load. Any help?

1 Solution

Accepted Solutions
andrey_krylov
Specialist
Specialist

Hi, Mark. Try this

Left Join(Items)

Load

     [Key],

     [Main],

     Max([Item Date]) as [Item Date],

     'Y' as [Max Main]

Resident Items where [Main] = 'Y'

Group by [Key], [Main];

View solution in original post

1 Reply
andrey_krylov
Specialist
Specialist

Hi, Mark. Try this

Left Join(Items)

Load

     [Key],

     [Main],

     Max([Item Date]) as [Item Date],

     'Y' as [Max Main]

Resident Items where [Main] = 'Y'

Group by [Key], [Main];