Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
kunkumnaveen
Specialist
Specialist

How to assign a flag

Hi All,

I Need to set a Flag 1 for all the Years and Quarters which are less then Q22019.

I tried below thing but its not working

if(QuarterYear_New<=YearQuarter,1,0) as Year_Flag;

 

Capture.PNG

 

So for all the QuarterYears below Q22019 should be assign a Flag 1 less 0

 

 

Below is the Script:

YearQuarter:
load *,
if(QuarterYear_New<=YearQuarter,1,0) as Year_Flag;

load *,
PurgeChar(QuarterYear,' ') as QuarterYear_New,
'Q' & Ceil(Month(Date#(today(), 'M/D/YYYY'))/3)&Year(Date#(today(), 'M/D/YYYY')) as YearQuarter

Resident QuarterYear;
Drop Table QuarterYear;

 

1 Solution

Accepted Solutions
sultanam
Contributor III
Contributor III

Try this one once

if(Right(QuarterYear_New,4)>Right(YearQuarter,4) or (left(PurgeChar(QuarterYear_New,'Q'),1)>left(PurgeChar(YearQuarter,'Q'),1) and Right(QuarterYear_New,4)>=Right(YearQuarter,4)),0,1) as Year_Flag;

View solution in original post

5 Replies
sultanam
Contributor III
Contributor III

Hi Naveen,

 

Please try below logic 

Load *,

if(right(QuarterYear_New,4)<=right(YearQuarter,4),1,0) as Year_Flag;

Regards,
Sultan

kunkumnaveen
Specialist
Specialist
Author

HI , your expression works only at Year Level ignoring Quarters , I Mean as shown below

Capture.PNG

Q32019 and Q42019 it suppose to be 0 instead of 1 because Q3 and Q4 is greater than Q2

kunkumnaveen
Specialist
Specialist
Author

Hello All , Any Suggestion  for achieving above requirement plz

sultanam
Contributor III
Contributor III

Try this one once

if(Right(QuarterYear_New,4)>Right(YearQuarter,4) or (left(PurgeChar(QuarterYear_New,'Q'),1)>left(PurgeChar(YearQuarter,'Q'),1) and Right(QuarterYear_New,4)>=Right(YearQuarter,4)),0,1) as Year_Flag;

kunkumnaveen
Specialist
Specialist
Author

Super .....Thanks It Worked