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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
aldo-tgh
Partner - Creator II
Partner - Creator II

FirstSortedValue with TOTAL by dimension

Hi Guys,

Need help with the following.

my data set has the following fields:  Storekey, Sessionkey, Itemkey, scene_date, and distributed, like:

_StoreKey1 _SessionKey1 scene_dateSum(distributed)
92
25450a07/01/201450
25487c08/01/20144
70479807/01/201422
70402a14/01/201416

I am trying to sum distributed in last scene_date  of each storekey.

In the example attached,

last session for store 254 is on 08/01/2014 the count=4

last session for store 704 is on 14/01/2014 the count=16

I need to be able to create both, a table and a list box, like:

_StoreKey1 # of distributed items Last Session # of distributed items on LAST SESSION
92 20
2545408/01/20144
7043814/01/201416

and also need to show that calculation (green field) into a List Box.

I am trying to use FirstSortedValue, something like:

FirstSortedValue( TOTAL <_StoreKey1,Sessionkey> distributed ,-scene_date)

but getting NULL since there are more than 1 resulting lines for each combination of Store & Session & Scene_Date because of Itemkey.

How do I work it around?

Thanks in advance for any help.

Aldo.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Ok, that makes a bit more sense.

='Total number of distributions based on the last session per store: ' & sum(aggr(FirstSortedValue(aggr(Sum(distributed),_StoreKey1,scene_item_date) ,-aggr(scene_item_date,_StoreKey1,scene_item_date)),_StoreKey1))


talk is cheap, supply exceeds demand

View solution in original post

10 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

FirstSortedValue(aggr(Sum(distributed),_StoreKey1,scene_item_date),-aggr(scene_item_date,_StoreKey1,scene_item_date))


talk is cheap, supply exceeds demand
aldo-tgh
Partner - Creator II
Partner - Creator II
Author

Hi Gysbert,

Thanks for your answer.

Almost there.

Please note the Total for the expression should be 20 and not 16.

What is missing?

Thanks,

Aldo.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Set the total mode for the expression to Sum of Rows instead of Expression Total


talk is cheap, supply exceeds demand
aldo-tgh
Partner - Creator II
Partner - Creator II
Author

That's great, but still need to work around the expression in order to use it on a List Box.

Aldo.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Why do you want it in a list box? You won't be able to select it.


talk is cheap, supply exceeds demand
aldo-tgh
Partner - Creator II
Partner - Creator II
Author

my user need to see the total number of distributions into selected  stores.

Based on last session for each store.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

That's the total in the table... precisely where the context is too so the user can understand where it comes from and what it means.


talk is cheap, supply exceeds demand
aldo-tgh
Partner - Creator II
Partner - Creator II
Author

I mean TEXT Box - not List Box - Sorry!

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Ok, that makes a bit more sense.

='Total number of distributions based on the last session per store: ' & sum(aggr(FirstSortedValue(aggr(Sum(distributed),_StoreKey1,scene_item_date) ,-aggr(scene_item_date,_StoreKey1,scene_item_date)),_StoreKey1))


talk is cheap, supply exceeds demand