Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

MTD VIA SET ANALYSIS

Hi Team,

My Data look like this---

NameDateAmount
aa23-01-20151119
aa11-04-20151197
aa28-06-20151275
aa14-09-20151353
aa01-12-20151431
aa17-02-20161509
aa05-05-20161587
aa22-07-20161665
aa08-10-20161743
aa30-11-20151300

Here my max year and month is 2016 and Oct, now i want calculate previous month amount of max year i.e for July month..

I have implemented the following logic but the result is zero because in MonthID the monthID is coming for sep but i want it to come for July

=Sum({$<MonthID = {$(=Max(MonthID) -1)},

        Year = ,

        Quarter = ,

        Month = >} Sales) 

Labels (1)
3 Replies
shawn-qv
Creator
Creator

It makes sense that max(MonthID)-1 = Sep, because your max month is Oct. So Oct-1 will return Sep.


I think you need to define your MTD. Based on your expression, it will return the MonthID of every year because you're ignoring the Year field.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Use this:

=firstsortedvalue(Date, -Date, 2)

ie like this:

=Sum({<Date = {"=$(=firstsortedvalue(Date, -Date, 2))"},

Year = , Quarter = , Month = >} Sales) 

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jvishnuram
Partner - Creator III
Partner - Creator III

Hi Sumit,

Try this

Sum({$<MonthID = {"$(=Max(MonthID) -1)"},

        Year = {"$(=Max(Year))"},

        Quarter = ,

        Month = >} Sales)

VJ