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

to compare datefields with each other (inkl. string)

Hi Folks,

i got a Question, i have tow datafields:

Field1                  Field2

01.01.2019        06.01.2019

03.01.2019        not planned

04.01.2019        12.01.2019

 

i want compare two fields with each other,  namely

if( Field1 < Field2, Field2,

if( Field1 > Field2, Field1,

if(Filed2 = 'not planned', Field1,'another case'))) as Controll,

 

but because of Filedvalue: not planned i am not able to compare These fields,

Does anybody know how to resolve this issue: if Field2 has the textvalue: 'not planned' then the Field1 should be taken.

 

Thanks a lot

Beck

Labels (1)
1 Solution

Accepted Solutions
JordyWegman
Partner - Master
Partner - Master

Yes, that is correct. That is because it evaluates first if Field1 < Field2. This will not be correctly understood (in your way of thinking) by the Qlik Engine and give a false answer (for your wanted outcome). You should place it in front.

If your problem is solved, please mark this as solved.

Work smarter, not harder

View solution in original post

8 Replies
JordyWegman
Partner - Master
Partner - Master

Hi Beck,

Try this for example:

IF(Field2 = 'not planned', Field1, if(Field1 < Field2, Field2, Field1))

Kind regards,

Jordy

Climber

Work smarter, not harder
beck_bakytbek
Master
Master
Author

Hi Jordy,

thanks a lot for your responce and time, i have implemented and it does work, i have onle placed this Expression at in the first place in Expression, but i place this part of Expression in last place, then it does not work.

 

Do you have any idea how to define this behaviour within of Expression?

JordyWegman
Partner - Master
Partner - Master

Hi Beck,

I'm not completely sure what you mean. Can you upload a screenshot of what  you are trying to create?

Jordy

Climber

Work smarter, not harder
beck_bakytbek
Master
Master
Author

i mean this Situation:

if i use this Expression: 

 

if(Field1 < Field2, Filed2

if(Field2 = 'not planned', Field1, 'another case')))   as  you see i placed: if(Field2 = 'not planned', Field1, 'another case') on second place then it does not work

 

but if i placed it on first place like:

 if(Field2 = 'not planned', Field1, 

if(Field1 < Field2, Field2, 'not planned')) then it does  work

 

marcus_sommer

If you don't want to change the order of your conditions you could also use: alt(Field2, 0) or maybe alt(Field2, addyears(today(), 100) to replace the string with a numeric default-value (it might be also useful to adjust this already within the script).

- Marcus

beck_bakytbek
Master
Master
Author

Hallo Marcus,

thanks a lot for your help and time

 

P.S: Vielen Dank

JordyWegman
Partner - Master
Partner - Master

Yes, that is correct. That is because it evaluates first if Field1 < Field2. This will not be correctly understood (in your way of thinking) by the Qlik Engine and give a false answer (for your wanted outcome). You should place it in front.

If your problem is solved, please mark this as solved.

Work smarter, not harder
beck_bakytbek
Master
Master
Author

Thanks a lot for your time and help