Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
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 !!!

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
Champion

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