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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
gautik92
Specialist III
Specialist III

MTD

How to calculate the MTD value

15 Replies
gautik92
Specialist III
Specialist III
Author

for Previous MTD

PrashantSangle

Hi,

=sum({<Year={$(=Max(Year))},Transactiondate={">=$(=MonthStart(Addmonths(max(Transactiondate),-1)))"}>} Qty)

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
perumal_41
Partner - Specialist II
Partner - Specialist II

=sum({<Year={$(=Max(Year))},Transactiondate={">=$(=MonthStart(addmonths(max(Transactiondate),-1))),<=$(=MonthEnd(addmonths(max(Transactiondate),-1)))"}>} Qty)

Not applicable

MonthStart function returns first date of month.

As I imagine , if you have to compare the same data bank for the previous year, you should add an upper limit to the function range:

MonthStart(Max(DATE)) ---> Max(Transactiondate)

However, you should generate all the variables you need for your "time analysis" directly in the load script.

You can do this by loading a temporary table and then generate all the variables using peek function, here is an example:

date.jpg

Not applicable

If you need to analyze the same MTD period in previous month you can use:


=sum({<Year={$(=Max(Year))},Transactiondate={">=$(=AddMonths(MonthStart(max(Transactiondate)),-1)) <= $(=AddMonths(max(Transactiondate)),-1)"}>} Qty)


Otherwise, if you need do calculate total sum for previous month you can use:


=sum({<Year={$(=Max(Year))},Transactiondate={">=$(=MonthStart(AddMonths(max(Transactiondate),-1))) <= $(=MonthEnd(AddMonths(max(Transactiondate),-1)))"}>} Qty)




Not applicable

Anyway, I don't understand why you set year field before the ecplicit date limitation (which already contains implicitly the year limitation).

You should remove it i think