4 Replies Latest reply: Apr 14, 2017 12:50 AM by Rahul Pawar

# Max date in data

Hi,

New to qlik sense, I have a dataset like the one below, where I need to summarize last month's sales.

My result should be Sales for last month-> March 2016 = \$78

How can I do this in a set analysis?

I have tried sum ({< [Month Year] = {'\$(=Max(Date))'} >}  [Sales])  but no luck.

 Customer Month Year Sales A 1/1/16 \$10 B 1/1/16 \$11 C 1/1/16 \$12 D 1/1/16 \$13 A 2/1/16 \$14 B 2/1/16 \$15 C 2/1/16 \$16 D 2/1/16 \$17 A 3/1/16 \$18 B 3/1/16 \$19 C 3/1/16 \$20 D 3/1/16 \$21
• ###### Re: Max date in data

Can you tie a master calendar to the date field then use set analysis to filter by month and year?

• ###### Re: Max date in data

Something similar to SUM({<[Year]={\$(=Year(Today()))}, [Month]={\$(=Month(Today()))}>} Sales)

• ###### Re: Max date in data

Try like:

sum ({< [Month Year] = {'>=\$(=MonthStart(Max(Date))) <=\$(=MonthEnd(Max(Date)))'} >}  [Sales])

• ###### Re: Max date in data

Hello Monica,

Trust that you are doing well!

```=Num(Sum({<[Month Year]= {'\$(=Date(Max([Month Year]), 'M/D/YY'))'}>}Sales), '\$#,##0;(\$#,##0)')
```