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: 
klrameet
Contributor III
Contributor III

Issue with FirstSortedValue expression, returning two values instead of one

Hi

My expression using FirstSortedValue () is returning two values, I even tried using IF to filter additional rows, but that just changed the output from getting C & F to F & -

Original:

=Aggr(FirstSortedValue(DISTINCT [FEED_REPORT_STATUS_LOG_QV.STATUS],-[FEED_REPORT_STATUS_LOG_QV.VERSION_NO]),[FEED_REPORT_STATUS_LOG_QV.COB_DATE],[FEED_REPORT_STATUS_LOG_QV.REP_NAME],EVENT_RANK)

Output: C & F

Modified:

=if(EVENT_RANK =1,Aggr(FirstSortedValue(DISTINCT [FEED_REPORT_STATUS_LOG_QV.STATUS],-[FEED_REPORT_STATUS_LOG_QV.VERSION_NO]),[FEED_REPORT_STATUS_LOG_QV.COB_DATE],[FEED_REPORT_STATUS_LOG_QV.REP_NAME],EVENT_RANK))

Output: F & -

 

AS.png

@sunny_talwar 

Labels (4)
9 Replies
klrameet
Contributor III
Contributor III
Author

following 

Anil_Babu_Samineni

What are you expecting the value, Is that based on event rank?

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
klrameet
Contributor III
Contributor III
Author

@Anil_Babu_Samineni  ..

I am trying to get the Status, for the Max Version (23 here) for a latest COB Date/Given COB Date for a Report Name with Event Rank = 1 

Anil_Babu_Samineni

Can't you simply write?

=FirstSortedValue(DISTINCT [FEED_REPORT_STATUS_LOG_QV.VERSION_NO], -[FEED_REPORT_STATUS_LOG_QV.COB_DATE])

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

May be this

FirstSortedValue(DISTINCT {<EVENT_RANK = {1}>} [FEED_REPORT_STATUS_LOG_QV.STATUS], -[FEED_REPORT_STATUS_LOG_QV.VERSION_NO])
klrameet
Contributor III
Contributor III
Author

FirstSortedValue(DISTINCT {<EVENT_RANK = {1}>} ,{[FEED_REPORT_STATUS_LOG_QV.EVENT_NAME] ={'BATCH'}>}[FEED_REPORT_STATUS_LOG_QV.STATUS], -[FEED_REPORT_STATUS_LOG_QV.VERSION_NO])

would this be right, if I have two conditions to be used in the expression ? (additional condition being [FEED_REPORT_STATUS_LOG_QV.EVENT_NAME] ='BATCH') 

sunny_talwar

This

FirstSortedValue(DISTINCT {<EVENT_RANK = {1}>},[FEED_REPORT_STATUS_LOG_QV.EVENT_NAME] = {'BATCH'}>}[FEED_REPORT_STATUS_LOG_QV.STATUS], -[FEED_REPORT_STATUS_LOG_QV.VERSION_NO])

You had an extra '{' in your expression

 image.png

klrameet
Contributor III
Contributor III
Author

Getting error for this expression .. 

sunny_talwar

My bad, try this

FirstSortedValue(DISTINCT {<EVENT_RANK = {1}, [FEED_REPORT_STATUS_LOG_QV.EVENT_NAME] = {'BATCH'}>}[FEED_REPORT_STATUS_LOG_QV.STATUS], -[FEED_REPORT_STATUS_LOG_QV.VERSION_NO])