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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

if statement in Script

Hi experts

I have this statement in the loading script:

if(date(Timestamp, 'YYYY-MMM')= date(Addmonths(MonthEnd(Today()),-1), 'YYYY-MMM'), [Event Reason]) as [Event Reason_new]

It is not working, although the date fields are correct in the app:

TomBond77_0-1708330800672.png

Any ideas?

 

1 Solution

Accepted Solutions
brunobertels
Master
Master

hi 

try 

if(date(floor(Timestamp), 'YYYY-MMM')= date(Addmonths(MonthEnd(Today()),-1), 'YYYY-MMM'), [Event Reason]) as [Event Reason_new]

View solution in original post

3 Replies
brunobertels
Master
Master

hi 

try 

if(date(floor(Timestamp), 'YYYY-MMM')= date(Addmonths(MonthEnd(Today()),-1), 'YYYY-MMM'), [Event Reason]) as [Event Reason_new]

theoat
Partner - Specialist
Partner - Specialist

Good morning,

This doesn't work because you're comparing a date and a timestamp. (The date function is a formatting function.
Try this :
if(date(dayname(Timestamp), 'YYYY-MMM')= date(Addmonths(MonthEnd(Today()),-1), 'YYYY-MMM'), [Event Reason]) as [Event Reason_new]

Cordialement,
Théo ATRAGIE.

TomBond77
Specialist
Specialist
Author

solved it:

if(monthend(date(floor(Timestamp), 'YYYY-MMM'))= monthend(date(Addmonths(MonthEnd(Today()),-1), 'YYYY-MMM')), [Event Reason]) as [Event Reason_new] ,