Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Emil_bros
Contributor III
Contributor III

same month of last year calculation

Hi,

I need to calculate last year data  - for each month separately (and ideally for totals). Like in pivot below:

Capture.JPG

 

I use addMonths function but it won't work.

My formula is: 

sum({<POS_Month= {'$(vPOS_LY)'}>} Sell_Out)

where:

vPOS_LY:     =date(addMonths(POS_Month,-12), 'YYYY-MM')

any ideas where I am wrong?

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Try this

Before(Sum({<POS_Month>}Sell_Out), 12) * Avg(1)

View solution in original post

3 Replies
zhadrakas
Specialist II
Specialist II

Addmonth() is expecting a date. maybe try like this.

 

 

 

Date(AddMonths(POS_DATE,-12), 'YYYY-MM')
Date(AddMonths(MakeDate(POS_YEAR, POS_MONTH, 1),-12), 'YYYY-MM')

 

sunny_talwar

Try this

Before(Sum({<POS_Month>}Sell_Out), 12) * Avg(1)
Emil_bros
Contributor III
Contributor III
Author

your're right Sunny, as always. Thank you!