Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
tvanlaun
Contributor II
Contributor II

Re-using the FirstSortedValue on subsequent rows

Hi experts

In my data set, I'm trying to get the earliest stock price for each stock, based on the users' selections of both stocks and dates.  This is so I can show a % movement, always starting with a base of 100% for each stock, regardless of the user's selection.

Below is a sample data set and how I'd like the output to look.

I've got as far as FirstVal = aggr(FirstSortedValue(Close,Date),Co)

(I'm not sure why this appears only on the second line!)

What I would like to understand is:  How do I get the First Val on to every line, so that I can use it to calculate the stock price re-based to the user's date range?

Many thanks!

    

DateCoCloseFirst Val
21/03/2017Co A84.42-
22/03/2017Co A82.7184.42
23/03/2017Co A82.95-
24/03/2017Co A83.38-
27/03/2017Co A83.4-
28/03/2017Co A85.26-
29/03/2017Co A86.14-
21/03/2017Co B43.92-
22/03/2017Co B43.2943.92
23/03/2017Co B43.4-
24/03/2017Co B43.88-
27/03/2017Co B44-
28/03/2017Co B44.38-
29/03/2017Co B44.88-
21/03/2017Co C34.32-
22/03/2017Co C33.4934.32
23/03/2017Co C33.44-
24/03/2017Co C33.9-
27/03/2017Co C34-
28/03/2017Co C34.7-
29/03/2017Co C35.14-
21/03/2017Co D25.82-
22/03/2017Co D25.4325.82
23/03/2017Co D25.61-
24/03/2017Co D25.94-
27/03/2017Co D25.94-
28/03/2017Co D26.25-
29/03/2017Co D26.35-

2017-10-25_10-04-34.png

1 Reply
tvanlaun
Contributor II
Contributor II
Author

Answered my own question!  I posted this after ages trying to crack it.  As soon as I returned to the problem after posting, I figured it out:

aggr( NODISTINCT FirstSortedValue(Close,Date),Co)


Hope this helps someone in the future.