# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Rules, plus terms and conditions, can be found here.
New Contributor II

## Output of the expression

What is the exact meaning of this expression and what will be the output?

=FirstSortedValue({<Paid_Date = {"<=\$(=Date(Upto,'D/M/YYYY')) "}>} Outstanding,-Paid_Date)

1 Solution

Accepted Solutions
Valued Contributor

## Re: Output of the expression

It gives the 1st value of the Outstanding with the max Paid_Date  which is less that the selected Upto Date.

8 Replies
Valued Contributor

## Re: Output of the expression

It gives the 1st value of the Outstanding with the max Paid_Date  which is less that the selected Upto Date.

New Contributor II

## Re: Output of the expression

Could you please explain how its giving me the maximum paid date.

Also.. what does (-Paid_Date) indicate?

Valued Contributor

## Re: Output of the expression

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. (FirstSortedValue())

So if we keep "-" before the field B, it will be sorted in reverse order, returning B which is value for Max value in FieldB.

Same is the case with PaidDate(field B) and outstanding(Field A).

And again set analysis is applied to filter the values based on FieldB.

New Contributor II

## Re: Output of the expression

So..it will fetch the latest Paid_Date and will give the outstanding on the basis of this latest Paid_Date...Am I right Shiva?

Valued Contributor III

## Re: Output of the expression

... as long as there's exactly one distinct value matching...

New Contributor II

## Re: Output of the expression

Thanks Robin. I got my answer.

Valued Contributor

## Re: Output of the expression

Latest paid Date which is less than selected "Upto" value

New Contributor II

## Re: Output of the expression

Thank you so much Shiva for solving this query.