Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

FirstSortedValue with equal values

Hello,

I have the following table:

WaveActivityDateContactIDNPSSegment
101/01/2018ANeutral
101/01/2018ANeutral
101/01/2018BDetractor
101/01/2018CPromotor

And the following script:

NPSSegments:
LOAD FirstSortedValue(NPSSegment,-ActivityDate) as NPSSegmentPre,
//avg(round(NPSScore)) as AvgNPSScore,
  ContactID
Resident NPSPreload
Where Wave = '0'
Group By ContactID;


For ContactID A, there is no value. For B & C, there is.

The issue I'm having is with the ContactID A.


How can I make the script "pick" one (the latest based on the sorting of the load script) when the activity date is the same?

Now it's just returning nothing.


As always, any help is greatly appreciated!


Kind regards,

Christophe

1 Solution

Accepted Solutions
sunny_talwar

Try this

FirstSortedValue(DISTINCT NPSSegment,-ActivityDate) as NPSSegmentPre,

View solution in original post

4 Replies
sunny_talwar

Try this

FirstSortedValue(DISTINCT NPSSegment,-ActivityDate) as NPSSegmentPre,

Anonymous
Not applicable
Author

It worked, thanks!

Anonymous
Not applicable
Author

One more thought on this though:

What if one contact has 2 different values on the same day. Which one will it pick? And will it produce the same "issue"?

sunny_talwar

It will pick on of them randomly. But is there a preference to what should be picked?