Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
rfigueroa
Contributor III
Contributor III

Expression to compare with first value

Hi,

In the example attached, I would like to add a fourth column so their value will be the current Quantity minus the Quantity value from the first Purchase for the same Product.

For example for product A, Fx will be Qty - 10 which is the value from the first purchase:

productID  dtPurchase  Quantity  Fx

   A       01/01/2000       10      0

   A       01/02/2000       9       1

   A       01/03/2000       8       2

I know that's very simple for you guys...hope can you help me.

Thanks in advance.

Cheers.

Roberto

1 Solution

Accepted Solutions
johnw
MVP
MVP

This seems to be working, though I didn't check it particularly carefully:

Quantity-firstsortedvalue(total <productID> Quantity,dtPurchase)

View solution in original post

4 Replies
matt_crowther
Luminary
Luminary

Roberto,

Try top(Quantity) as you'r expression - it works for me in your example file.

You can of course use top(total Quantity) to take the very first record.

Hope that helps,

Matt - Visual Analytics Ltd

rfigueroa
Contributor III
Contributor III
Author

Thank you Matt, but seems the results change when we change the order. I need an expressions that returns always the first Quantity value from the first purchase for each product.

Robert.

johnw
MVP
MVP

This seems to be working, though I didn't check it particularly carefully:

Quantity-firstsortedvalue(total <productID> Quantity,dtPurchase)

View solution in original post

rfigueroa
Contributor III
Contributor III
Author

works perfect! thank you John.