Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Umeiko
Partner - Contributor II
Partner - Contributor II

How to use FirstSortedValue() to aggregate 2 or more values

I load CustProjectData  script (on QlikSense Desktop)  as belows:

===============================

CustProjectData:

LOAD * inline [
CustName|Project|DataYrMon|Backlog
Astrida|AA|202311|1131313
Astrida|AA|202312|1141233
Astrida|BB|202311|14152
Astrida|BB|202310|14122
Betacab|CC|202311|101111
Betacab|CC|202312|122222
Betacab|CC|202310|222222
Betacab|CC|202309|201111
Betacab|DD|202312|250000
Canutility|EE|202312|15000
Canutility|EE|202310|11100
Canutility|FF|202310|19000
] (delimiter is '|');

=================================

I am developing a table as belows, I use 

firstsortedvalue (Distinct Backlog, -DataYrMon) 

to get the lastest year-month's backlog value, and it's correct.

Now I need to aggregate the same CustName's measures together as noted on the following picture.

How do I do to get the correct caculations? 

FirstSortedValue-Agg.png

Please help and many thanks.

I Mei, Huang
Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

Maybe adding Project to aggr() like:

sum(total <CustName> aggr(firstsortedvalue (Distinct Backlog, -DataYrMon), CustName, Project))

View solution in original post

6 Replies
marcus_sommer

Try it with:

sum(aggr(firstsortedvalue (Distinct Backlog, -DataYrMon), CustName))

Umeiko
Partner - Contributor II
Partner - Contributor II
Author

I tried the caculation but it doesn't work, it shows as the most right column...

Umeiko_0-1704758725163.png

 

I Mei, Huang
marcus_sommer

Try it with extending the calculation with:

sum(aggr(nodistinct firstsortedvalue (Distinct Backlog, -DataYrMon), CustName))

or

sum(total <CustName> aggr(firstsortedvalue (Distinct Backlog, -DataYrMon), CustName))

Umeiko
Partner - Contributor II
Partner - Contributor II
Author

Thanks. however, I tried both caculations, they don't work as expecting...

The first one(red column) seems use the first Backlog value multiplys by project counts and repeat,

and the second one (blue column) seems just repeat the first Backlog value.

both caculations don't meet requirements.

Umeiko_0-1704794098833.png

 

I Mei, Huang
marcus_sommer

Maybe adding Project to aggr() like:

sum(total <CustName> aggr(firstsortedvalue (Distinct Backlog, -DataYrMon), CustName, Project))

Umeiko
Partner - Contributor II
Partner - Contributor II
Author

Many many thanks!! It works

Umeiko_0-1704936539914.png

 

I Mei, Huang