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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
marikabi
Creator
Creator

FirstSortedValue issue

Hi all,

I am trying to find the week in 2016 in which the total traffic volume per country was the highest one.

To find the max traffic volume I am using:

MAX(aggr(sum({<[YEAR]={'2016'}>}[TRAFFIC]),WEEK,COUNTRY))

and in order to find the week I am using:

FirstSortedValue(WEEK, -Aggr(sum({<[YEAR]={'2016'}>}[TRAFFIC]),WEEK))

The problem is that this second function works only when a specific country is filtered, but if nothing is filtered it gives me back "-".

I would like to have all the values, without having to filter them...

Any idea?

Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

My bad, can you try this (I misplaced Country in my previous response):

FirstSortedValue(WEEK, -Aggr(sum({<[YEAR]={'2016'}>} [TRAFFIC]), Country, WEEK))

View solution in original post

16 Replies
vishsaggi
Champion III
Champion III

May be this:


= FirstSortedValue(WEEK,  -Aggr(sum({<[YEAR]={'2016'}>}[TRAFFIC]), YEAR, COUNTRY, [TRAFFIC]))

marikabi
Creator
Creator
Author

Hi,

it works only for few rows:

it gives me back a value for all the countries, but sometimes it is a wrong value...

sunny_talwar

How about this:

FirstSortedValue(WEEK, -Aggr(sum({<[YEAR]={'2016'}>} Country, [TRAFFIC]),WEEK))

marikabi
Creator
Creator
Author

Hi,

the expression is OK for Qlik, but it gives me back no results, even if I filter something....

sunny_talwar

Would you be able to share a sample?

vishsaggi
Champion III
Champion III

Oops i missed the week May be try this:

= FirstSortedValue(WEEK,  -Aggr(Only(sum({<[YEAR]={'2016'}>}[TRAFFIC])) , Country, WEEK , [TRAFFIC]))

marikabi
Creator
Creator
Author

In this case no results at all all the lines gives me back this : "-"

marikabi
Creator
Creator
Author

Actually I am not able to attach the qvw file.

Here is an example of what I need:

   

COUNTRYTOP TRAFFIC VOLUME (min)WEEK
A105410

Having for this specific country these values:

   

1591
14208
13103
1264
1130
101,054
9235
8301
7259
6157
5213
4135
3133
2153
1138
vishsaggi
Champion III
Champion III

As sunny said, it would be good if you can share your sample app for a quick look.

Can you try below as well?

What is your date field in your table like,

= FirstSortedValue(WEEK,  -Aggr(sum({<[YEAR]={'2016'}>}[TRAFFIC]) , Yourdatefield , WEEK , [TRAFFIC]))