Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
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

16 Replies
marikabi
Creator
Creator
Author

Actually, I can't share the application for two reasons:

1) privacy

2) the company is now discussing with the vendors to buy the client licenses and I still don't have it...

What I can't understand is why the formula I was using gave me the correct result only when filtering... Do you think it was a my coding mistake?

vishsaggi
Champion III
Champion III

We are not sure how your data model and script looks like hence asked for a sample. YOu might want to look into this to scramble your data to protect data privacy to upload.

Preparing examples for Upload - Reduction and Data Scrambling

Anil_Babu_Samineni

Yes, we also can understand your problem over there

1) That's why we are creating dummy data with same Fields

2) Don't require license because if you need DOC for this we can help to create Doc for you. Or atleast we can understand what you did and what we suppose to do.

Try for me using $.

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


Learning from stalwar1


Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

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

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

marikabi
Creator
Creator
Author

Many, many, many thanks!

It works perfectly

And thanks to all of you for having helped me

sunny_talwar

Is it still not resolved? I thought it was?

marikabi
Creator
Creator
Author

Yes it is

The moderator has approved this content with some delay...

As you can see I posted that reply right after your one ..

thanks again!!