# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Contributor

## Firstsortedvalue filter set analysis

I need to calculate last purchase by client from product 1, made before 201712 (YYYYMM)

Sum all that (above) and divided by distinct client, in order to get the AVG expense by client.

I tried using firstsortedvalue, but I didn´t figure it out how to put those filters in firstsortedvalue function.

Aggr( firstsortedvalue( SALES, -INVOICE_DATE,2), ICC)

I have that formula above, but how I tell to this formula to:

- only look in transactions before  201712. Variable name is YEARMONTH

- only in transactions from product 1.  Variable name is PRODUCT

Any help for set analysis approach in QlikSense?

Tags (2)
1 Solution

Accepted Solutions
Honored Contributor II

## Re: Firstsortedvalue filter set analysis

maybe this:

Aggr( firstsortedvalue(  {<  PRODUCT= {'1'}, YEARMONTH = {"<201712"} >} SALES, -INVOICE_DATE,2), ICC )

2 Replies
Honored Contributor II

## Re: Firstsortedvalue filter set analysis

maybe this:

Aggr( firstsortedvalue(  {<  PRODUCT= {'1'}, YEARMONTH = {"<201712"} >} SALES, -INVOICE_DATE,2), ICC )

Contributor

## Re: Firstsortedvalue filter set analysis

Thank you agigliotti, that was a perfect solution!!

Regards