Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
aheavy95
Creator
Creator

addmonth in where clause

Hi all 
I am trying to load in a loop the closing inventory of the previous month each time.

The  "Sale_Year_Month" field is formatted '01/07/2023' (The alias  is confusing )

My problem is in the where clause. The previous one which is greyed, worked fine (where Sale_Year_Month='$(YM)'-1)

But as I am trying to use the addmonth function so it works also when the year changes- the where clause Sale_Year_Month=AddMonths('$(YM)',-1)  isn't working and I'm getting an empty table. I guess I am missing some syntax.

aheavy95_0-1699447796522.png

Thanks

Labels (4)
1 Solution

Accepted Solutions
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi,

Check the YM variable.

It is returning the 7.06 value. It should return some Date right ?

AshutoshBhumkar_0-1699452614524.png

AshutoshBhumkar_1-1699452739322.png

 

Please correct me if I understood this in another way.

 

Thanks,
Ashutosh

 

 

View solution in original post

3 Replies
Or
MVP
MVP

Best guess would be that Sale_Year_Month isn't picked up as a date. Have you tried explicitly converting it to a date using date#()?

aheavy95
Creator
Creator
Author

I loaded the script without the where clause:

aheavy95_1-1699452446210.png

 

 the Sale_Year_Month is picked up as a date, but I inserted the-  addmonths('$(YM)',1) as Sale_Year_MonthNew and it seems like the problem occurs with that expression

aheavy95_0-1699452309771.png

 

 

AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hi,

Check the YM variable.

It is returning the 7.06 value. It should return some Date right ?

AshutoshBhumkar_0-1699452614524.png

AshutoshBhumkar_1-1699452739322.png

 

Please correct me if I understood this in another way.

 

Thanks,
Ashutosh