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

if else condition

Hi Team,

I am facing issue with one logic. I have two date field Start Date and End Date.

I want if Start Date=End Date,then show Active and if StartDate<End Date, then show Expired.

If(Date(StartDate,'YYYY-MM-DD'),'Active',if(Date(End Date,'YYYY-MM-DD'),'Expired') as Status

But this is not working. Any idea how to resolve this?

2 Replies
swuehl
MVP
MVP

If( [Start Date] = [End Date], 'Active', If( [Start Date] < [End Date],'Expired','Not defined')) AS Status

assuming your dates have been interpreted as dates and are not in fact timestamps.

If you are unsure and the format of your input records is 'YYYY-MM-DD', try

SET DateFormat = 'YYYY-MM-DD';

LOAD

     [Start Date],

     [End Date],

     If( Floor([Start Date]) = Floor([End Date]), 'Active', If( Floor([Start Date]) < Floor([End Date]),'Expired','Not defined')) AS Status,

...

MindaugasBacius
Partner - Specialist III
Partner - Specialist III

If(Date(StartDate,'YYYY-MM-DD'),'Active',if(Date(End Date,'YYYY-MM-DD'),'Expired') as Status

In your IF statements there are no logic statement.


IF statement is defined as IF(condition, then, else). The first one, condition, is interpreted logically - TRUE, FALSE. The Date(StartDate,'YYYY-MM-DD') and Date(End Date,'YYYY-MM-DD') cannot be interpreted as condition that returns TRUE (-1), FALSE (0).


Please let as know if the swuehl suggestion works for you.