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: 
qlikview979
Specialist
Specialist

First Sorted value

Hi Experts,

What is First Sorted Value ? How it will work Share me with Example?

Regards,

Mahesh.

1 Solution

Accepted Solutions
7 Replies
ankit777
Specialist
Specialist

Hi

see the below link for reference

FirstSortedValue()

tresesco
MVP
MVP

Did you check Help? That is the best place to know about the functions. Check that and then search this community, you would get many useful discussions like: Firstsortedvalue Vs FirstValue Example

sujeetsingh
Master III
Master III

Follow the reference manual.

qlikview979
Specialist
Specialist
Author

Hi,

Can you  give with Example?

Regards,

Mahesh.

Kushal_Chawda

FirstSortedValue - chart function

FirstSortedValue() returns the value from the expression specified in value that corresponds to the result of sorting the sort_weight argument, taking into account rank, if specified. If more than one resulting value shares the same sort_weight for the specified rank, the function returns NULL.

Syntax:

FirstSortedValue([{SetExpression}] [DISTINCT] [TOTAL [<fld {,fld}>]] value, sort_weight [,rank])

Return data type: dual

Arguments:

ArgumentDescription
valueOutput field. The function finds the value of the expression value that corresponds to the result of sorting sort_weight.
sort_weight

Input field. The expression containing the data to be sorted. The first (lowest) value ofsort_weight is found, from which the corresponding value of the value expression is determined. If you place a minus sign in front of sort_weight, the function returns the last (highest) sorted value instead.

rank

By stating a rank "n" larger than 1, you get the nth sorted value.

SetExpressionBy default, the aggregation function will aggregate over the set of possible records defined by the selection. An alternative set of records can be defined by a set analysis expression.
DISTINCTIf the word DISTINCT occurs before the function arguments, duplicates resulting from the evaluation of the function arguments are disregarded.
TOTAL

If the word TOTAL occurs before the function arguments, the calculation is made over all possible values given the current selections, and not just those that pertain to the current dimensional value, that is, it disregards the chart dimensions.

The TOTAL qualifier may be followed by a list of one or more field names within angle brackets <fld>. These field names should be a subset of the chart dimension variables.

See: Defining the aggregation scope

Examples and results:

CustomerProductUnitSalesUnitPrice
AstridaAA416
AstridaAA1015
AstridaBB99
BetacabBB510
BetacabCC220
BetacabDD-25
CanutilityAA815
CanutilityCC-19
ExampleResult
firstsortedvalue (Product, UnitPrice)

BB, which is the Productwith the lowest UnitPrice(9).

firstsortedvalue (Product, UnitPrice, 2)

BB, which is the Productwith the second-lowest UnitPrice(10).

firstsortedvalue (Customer, -UnitPrice, 2)

Betacab, which is the Customerwith the Product that has second-highestUnitPrice(20).

firstsortedvalue (Customer, UnitPrice, 3)

NULL, because there are two values of Customer (Astrida and Canutility) with the samerank (third-lowest) UnitPrice(15).

Use the distinct qualifier to make sure unexpected null results do not occur.

firstsortedvalue (Customer, -UnitPrice*UnitSales, 2)

Canutility, which is the Customer with the second-highest sales order value UnitPrice multiplied by UnitSales (120).

Data used in examples:

ProductData:

LOAD * inline [

Customer|Product|UnitSales|UnitPrice

Astrida|AA|4|16

Astrida|AA|10|15

Astrida|BB|9|9

Betacab|BB|5|10

Betacab|CC|2|20

Betacab|DD||25

Canutility|AA|8|15

Canutility|CC||19

] (delimiter is '|');

Chanty4u
MVP
MVP

chk dis too

Home ‒ QlikView