# 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
Did you mean:
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;

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

Below is the Script:

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

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
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;

5 Replies
Contributor III

Hi Naveen,

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

Regards,
Sultan

Specialist
Author

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

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

Specialist
Author

Hello All , Any Suggestion  for achieving above requirement plz

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;

Specialist
Author
Super .....Thanks It Worked
Community Browser