Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

WHat is the FirstSortedValue()

Hey,

WHat is the FirstSortedValue() ?? Can anyone explain with example ??

Thanks

15 Replies
Not applicable

hi

firstsortedvalue([{set_expression}][ distinct ] [ total [<fld {, fld}>]] expression [, sort_weight [, n]])

returns the first value of expression sorted by corresponding sort-weight when expression is iterated over the chart dimension(s). Sort-weight should return a numeric value where the lowest value will render the corresponding value of expression to be sorted first. By preceding the sort-value expression with a minus sign, the function will return the last value instead. If more than one value of expression share the same lowest sort-order, the function will return null. By stating an n larger than 1, you will get the nth value in order.

Examples:

firstsortedvalue ( PurchasedArticle, OrderDate )     

firstsortedvalue ( PurchasedArticle, -OrderDate, 2 )     

firstsortedvalue ( A/B, X*Y/3 )    

firstsortedvalue ( distinct PurchasedArticle, OrderDate )     

firstsortedvalue ( total PurchasedArticle, OrderDate )    

firstsortedvalue ( total <Grp> PurchasedArticle, OrderDate )

Not applicable

hi

see link

FirstSortedValue()

ashfaq_haseeb
Champion III
Champion III

Hi,

Check this

http://qlikshare.com/tag/firstsortedvalue/

Regards

ASHFAQ

Not applicable

it will give the first value of expression based on the sort wait .sort wait should be numeric

ex:

table1:

A

B

C

D

table2:

1

2

3

4

if u write the expression firstsortedvalue(table1,table2)   output is D i.e is 4

if u go for firstsortedvalue(table1,-table2)  then lowest value   A i.e is 1

nikhilgarg
Specialist II
Specialist II
Author

HEy,

If i use 

firstsortedvalue ( PurchasedArticle, OrderDate ) 

then does it return PurchasedArticle value on basis of Minimum OrderDate ??

And if i use firstsortedvalue ( PurchasedArticle, -OrderDate )

then does it return PurchasedArticle value on basis of Maximum OrderDate ??

Is it so ??

Not applicable

if u use - symbol then it gives minimum value

if u have no symbol then it gives maximum value

Not applicable

firstsortedvalue(ValueField, WeightField)

It will give you the first sorted value of the ValueField depending on the specified WeightField.

eg. firstsortedvalue(AccountBalance,ReportDate)

This will return the value of AccountBalance on the first date as per the date variable.

Hope this helps

nikhilgarg
Specialist II
Specialist II
Author

Hey,

firstsortedvalue(AccountBalance,ReportDate)

will return AccountBalance corresponding to Maximum Report Date ??

Not applicable

no, it will return for minimum report date, if you want it to return for maximum report date then you can edit the expression as firstsortedvalue(AccountBalance,-ReportDate)

and the variable for weight may not necessarily be a date variable, you can use any other variable also.