Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Kirsten
Creator II
Creator II

IF Statement expression for calculated field

I need to create a calculated field with a False True statement

If  monthY < monthX   = True  else False

I am currently using  not date fields but  201910    202002 in numbers 

But also datafields: 01-02-2020  and 31-7-2019

What is the expression for this calculated field for both numbers and dates?

 

1 Solution

Accepted Solutions
Taoufiq_Zarra

if i understood correctly :

=if(ValueX > ValueY,'True','Fals')
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

6 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

it doesn't matter if you use numbers or dates 
because dates are numbers in different format 
so the if statement will work both for numbers and dates 

Kirsten
Creator II
Creator II
Author

Hi @lironbaram 

Thanks for the note

But what is the expression for an if statement in Qliksense? For a Date: e.g if  MonthY<MonthX  return 1 (or True) and if  MonthY>MonthX  return 0 (or False)

But also for a measure like this:

Sum([CM Hour.]) Count(Calls)    if  CMHour<Calls return 1 (or True) and if  CMHour>Calls  return 0 (or False)

Taoufiq_Zarra

Maye be :

if(alt(date#( monthY , 'DD-MM-YYYY' ),date#( monthY , 'YYYYMM' ))<alt(date#( monthX , 'DD-MM-YYYY' ),date#( monthX , 'YYYYMM' )),'True','False')

 

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Kirsten
Creator II
Creator II
Author

Thanks @Taoufiq_Zarra  will try this one out

And what if you are comparing normal numbers

If   ValueX > ValueY  True  and  if   ValueX < ValueY  False

Taoufiq_Zarra

if i understood correctly :

=if(ValueX > ValueY,'True','Fals')
Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Kirsten
Creator II
Creator II
Author

This one works thanks! I will try out the date if statement expression tomorrow