Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

FirstSortedValue()

Hi all,

i am new to qlikview just want to know that

how  FirstSortedValue() works in Qlikview... Can any one ive me a example ?

Load Customer,

firstsortedvalue(PurchasedArticle, OrderDate) as FirstProductBought from abc.csv

group by Customer;

???? i am unable to understand this through help also

Message was edited by: rohitkoul

1 Solution

Accepted Solutions
jsn
Honored Contributor

FirstSortedValue()

In that example it loads the instance of the PurchasedArticle based on the earliest OrderDate, i.e. the first product bought.

12 Replies
jsn
Honored Contributor

FirstSortedValue()

Imagine you have the following table:

FieldA, FieldB

A, 3

B, 4

C, 1

D, 2

If you run a FirstSortedValue(FieldA, FieldB) you'll get the first sorted value from FieldA based on the sorting of FieldB. Value 1 is the first value for FieldB so the function will in this example return C.

jsn
Honored Contributor

FirstSortedValue()

In that example it loads the instance of the PurchasedArticle based on the earliest OrderDate, i.e. the first product bought.

Not applicable

FirstSortedValue()

Thanks Johannes

if if(FirstSortedValue( likes ,-record_date,8)<>'',FirstSortedValue( likes ,-record_date)-FirstSortedValue( likes ,-record_date,2))

now what about this numeric value?

abhishek_bigdat
New Contributor II

Re: FirstSortedValue()

Go through this link

http://www.learnqlickview.com/first-sorted-value-function-in-qlikview/

Will help you learn it better.

Not applicable

Re: FirstSortedValue()

Hi Johannes

I woud like to get the last value for each customer.

If i use the firstSortedValue function, it return the first value but i need to get the last purchase for each customer.

For example

Customer      orderDate

Miguel           21/01/2014

Jose             20/06/2013

Carlos          20/06/2013

Miguel          20/11/2014

I want the output table look like this

Customer      orderDate

Miguel          20/11/2014

Jose             20/06/2013

Carlos          20/06/2013

Not applicable

Re: FirstSortedValue()

You can solve by

firstsortedvalue(Customer,-orderDate)

if we write - sign before the sort-weight i.e. orderDate here, it will return the last value.

santoshrai
New Contributor

Re: FirstSortedValue()

hi...Julisy...

I guess in your case only group by function will solve your purpose...to get desired out put...

try this

old:

LOAD customer,

     orderdate

FROM

(ooxml, embedded labels, table is [group by]);

new:

LOAD

  Distinct customer,

  max (date (orderdate))

  resident old

  Group by customer;

  DROP Table old;

qlikview979
Valued Contributor

Re: FirstSortedValue()

Hi ,

I am not able to open this link. can anyone give with example.

mvaugusto
Contributor

Re: FirstSortedValue()

Nice!

Community Browser