Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Problem with max() and aggr() function

Hi! I need a help.
Data (example):

ObjectManagerAppointment_date_manager
1Ivanov28.04.2016
1Petrov30.11.2017
1Sidorov10.09.2018
2Kuznetsov11.09.2018
3Petrov20.09.2018
3Kiselev21.09.2018
4Sidorov11.11.2016
4Kiselev20.04.2017
4Ivanov20.08.2018
5Sidorov20.09.2018
6Ivanov11.12.2017

What i need in a result (object's quantity of current manager):

ManagerQuantity of objects
Ivanov2
Petrov0
Sidorov2
Kuznetsov1
Kiselev1

Thanks for your ideas

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can flag the current managers in the script, but since you were calling for Aggr in the title, I guess you want a chart based solution, e.g.

Manager Sum(Aggr(If(Manager = FirstSortedValue(Total<Object> Manager, -Appointment_date_manager),1,0), Object, Manager))
6
Ivanov2
Kiselev1
Kuznetsov1
Petrov0
Sidorov2

View solution in original post

5 Replies
dplr-rn
Partner - Master III
Partner - Master III

Can you expand on logic behind the second table

benvatvandata
Partner - Creator II
Partner - Creator II

I'm assuming the Quantity of objects column in your example is based off a date range (using field Appointment_date_manager)?

swuehl
MVP
MVP

You can flag the current managers in the script, but since you were calling for Aggr in the title, I guess you want a chart based solution, e.g.

Manager Sum(Aggr(If(Manager = FirstSortedValue(Total<Object> Manager, -Appointment_date_manager),1,0), Object, Manager))
6
Ivanov2
Kiselev1
Kuznetsov1
Petrov0
Sidorov2
swuehl
MVP
MVP

Or using the script flag:

INPUT:

LOAD Object,

     Manager,

     Appointment_date_manager

FROM

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

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

DATA:

LOAD Object,

Manager,

Appointment_date_manager,

If(Previous(Object)<>Object,1,0) as Current

Resident INPUT

Order by Object, Appointment_date_manager desc;

DROP TABLE INPUT;

and in the UI

Manager Sum(Current)
6
Ivanov2
Kiselev1
Kuznetsov1
Petrov0
Sidorov2
Anonymous
Not applicable
Author

Thanks a lot! That's really what i need.