Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Mahamed_Qlik
Specialist
Specialist

Expain

Hi All,

Can somebody give me detail explanation of below Calculated dimesion:

=$(=FirstSortedValue('[' & %Dimension & ']',[%Dimension Position],1))

Regards,

Mahamed Khan

5 Replies
settu_periasamy
Master III
Master III

Hi,

This expression Will return the First %Dimension Field Value based on %Dimension Position Sorting. Normally Ascending order, if you give minus ' - ', it means Descending order.

For e.g  if you have the data like the below

[%Dimension][%Dimension Position]
Dim33
Dim21
Dim12

if you use =FirstSortedValue(%Dimension,[%Dimension Position]), you will get the result Dim2



from help:

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



=$(=FirstSortedValue('[' & %Dimension & ']',[%Dimension Position],1))


'[' & %Dimension & ']' 

    => This is just combining the field, suppose if you have space in the Field name.

          e.g  Employee Name returns = > [Employee Name]

    => 1 -> Just a record number

In the above, example, if you give =FirstSortedValue(%Dimension,[%Dimension Position],2)  => You will get 'Dim2'

See the Qlikview Help, if you need more info.


Anonymous
Not applicable

1) This expression will sort the all values of ,[%Dimension Position] field.
2) After that it will find the 1st value from the ,[%Dimension Position].
3) And finally it will return the corresponding value to the 1st value from %Dimension filed.

Let say:

%Dimension    %Dimension Position
A  4
B  2
C  1
D  3

=$(=FirstSortedValue('[' & %Dimension & ']',[%Dimension Position],1)) will return--> C

Hope this will help you…!!

Regards,
Sandip Satbhai

Mahamed_Qlik
Specialist
Specialist
Author

Hi Settu,

Thank you for your kind response.

Just want to know is there any specific need for entering record number (In Above example stated as value 1) or we can neglect tht as well?

Anonymous
Not applicable

settu_periasamy
Master III
Master III

Normally it gives the top value based on the Order. If you want the first value you can neglect it.