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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cannot compare variable with string in IF statement

Hi ,

Here is my script , but it's not working , i don't know if i'm missing something , please help :

If $(MoiCourant)='Janvier'  then

  EXECUTE cmd.exe /C rmdir /Q /S $(vCheminHomeQVD)QVDs_Avril$(vAnneePrecedante);

ELSE

    EXECUTE cmd.exe /C rmdir /Q /S $(vCheminHomeQVD)QVDs_Mars$(vAnneePrecedante);

END IF

it always do the Else , when i do a TRACE $(MoiCourant) it shows Janvier !!!

Labels (1)
1 Solution

Accepted Solutions
Not applicable
Author

I correct it , i just used the variable without $() , like this :

IF MoiCourant='Janvier'  then

Thank you for your answers

View solution in original post

4 Replies
anbu1984
Master III
Master III

Make sure there are no spaces after Janvier

srchilukoori
Specialist
Specialist

Enclose the variable in quotes.

If '$(MoiCourant)'='Janvier'  then

  EXECUTE cmd.exe /C rmdir /Q /S $(vCheminHomeQVD)QVDs_Avril$(vAnneePrecedante);

ELSE

    EXECUTE cmd.exe /C rmdir /Q /S $(vCheminHomeQVD)QVDs_Mars$(vAnneePrecedante);

END IF

SunilChauhan
Champion II
Champion II

use variable in single quotes


If '$(MoiCourant)'='Janvier'


hope this helps

Sunil Chauhan
Not applicable
Author

I correct it , i just used the variable without $() , like this :

IF MoiCourant='Janvier'  then

Thank you for your answers