Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to use 'Firstsortedvalue'

Hi all,
    I have a table contains data :
Date dis r sale
1 A X 24
1 C P 38
1 C Q 36
1 D X 31
1 D R 35
1 D T 33
2 A X 33
2 A Y 36
2 A Z 40
2 B X 34
2 B Y 37
2 B W 25
2 C P 25
2 C Q 22
2 D X 35
2 D R 29
2 D T 21
3 A X 39
3 A Y 32
3 A Z 21
3 B X 30
3 B Y 31
3 B W 20
3 C P 25
3 C Q 31
3 D X 36
3 D R 24
3 D T 29
4 A X 23
4 A Y 21
4 A Z 25
4 B X 28
4 B Y 21
4 B W 25
4 C P 36
4 C Q 29

I want to build a straight table which dimension is 'dis', and the expression
returns the first non-null total sales of date for each 'dis'.

I thought ahout firstsortedvalue, but don't how to use it.
Can anybody help me?

The attachement is my test qvw file. Thanks in advance.

Zhou

1 Solution

Accepted Solutions
Not applicable
Author

Hi Zhou,

I don't use firstsortedvalue() much.  You can get the desired result by using the following expression:

sum(aggr(if(Date=min(total <dis> Date), sum(sale)),dis,Date))

Karl

View solution in original post

2 Replies
Not applicable
Author

Hi Zhou,

I don't use firstsortedvalue() much.  You can get the desired result by using the following expression:

sum(aggr(if(Date=min(total <dis> Date), sum(sale)),dis,Date))

Karl

Not applicable
Author

Thank you Karl, it works.