Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
JoannaID
Contributor
Contributor

FirstSortedValue excluded 0's

Hi all,

I have such data, and need to get first sorted value for each product excluding 0’s.

I’ve tried to create Flag but it seems it doesn’t work.

 

Product

Document

DocType

date

Item Category

FlagPurchasePrice

Purchase Price

Product 1

40

P

2018-11-15

Marketing materials

1

3,90

Product 1

75

P

2018-11-19

Marketing materials

1

2,40

Product 1

11

P

2019-06-12

Marketing materials

1

4,80

Product 1

93

P

2019-09-20

Marketing materials

1

2,40

Product 1

63

P

2020-01-15

Marketing materials

1

3,47

Product 1

62

P

2020-07-10

Marketing materials

1

3,67

Product 1

90

P

2020-03-06

Marketing materials

1

1,75

Product 1

65

P

2020-08-07

Marketing materials

0

0,00

Product 2

39

P

2018-09-25

Marketing materials

1

73,00

Product 2

50

P

2019-01-03

Marketing materials

1

55,70

Product 2

20

P

2019-04-08

Marketing materials

1

58,00

Product 2

15

P

2019-05-24

Marketing materials

1

58,00

Product 2

73

P

2019-06-24

Marketing materials

1

58,00

 

Required result:

Product

Last Purchase Price

Product 1

1,75

Product 2

 

58

 

Tested expresions:

I was combinig FirstSortedValue with Aggr and Set Analysis… but still without success for product 1, I am affraid I am missing something…

FirstSortedValue({<FlagPurchasePrice={1}>}PURCHASE_PRICE, -date)

FirstSortedValue(aggr(only({<FlagPurchasePrice={1}>}PURCHASE_PRICE), FlagPurchasePrice, Product), -date)

max(Aggr(FirstSortedValue(PURCHASE_PRICE, FlagPurchasePrice, Product),FlagPurchasePrice))

Any ideas?

Thank You in advance 😊

Labels (3)
2 Replies
Chanty4u
MVP
MVP

Brett_Bleess
Former Employee
Former Employee

If the above post solved your issue, we would appreciate it if you would return to the thread to close things out by using the Accept as Solution button on the post with the suggestion to mark it.  

Here are some Design Blog posts that may be of some further help otherwise:

https://community.qlik.com/t5/Qlik-Design-Blog/Set-Analysis-in-the-Aggr-function/ba-p/1463822

https://community.qlik.com/t5/Qlik-Design-Blog/Don-t-get-aggr-avated-using-aggr/ba-p/1464136

Hopefully one of those may get you what you need if the other post did not get you all the way.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.