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

RAG for Quarter over Quarter Comparison

Hi All,

I want if total count of primary key is less than total count of Primary key of Previous quarter then mark that row with Green  else red.

suppose, if

 

DateQuarterPrimary Key
01-01-2016Q1 16abc
02-01-2016Q1 16abc
03-01-2016Q1 16abc
04-01-2016Q2 16pqr2
05-01-2016Q2 16pqr3
06-01-2016Q2 16pqr4
26-04-2016Q2 16pqr5
27-04-2016Q2 16pqr6
28-04-2016Q2 16pqr7
29-04-2016Q2 16xyz
30-04-2016Q2 16xyz
01-05-2016Q2 16xyz
29-10-2016Q4 16xyz
30-10-2016Q4 16xyz
31-10-2016Q4 16mno
01-11-2016Q4 16mno
02-11-2016Q4 16mno

should return

 

01-01-2016Q1 16abcGreen
02-01-2016Q1 16abcGreen
03-01-2016Q1 16abcGreen
04-01-2016Q2 16pqr2red
05-01-2016Q2 16pqr3red
06-01-2016Q2 16pqr4red
26-04-2016Q2 16pqr5red
27-04-2016Q2 16pqr6red
28-04-2016Q2 16pqr7red
29-04-2016Q2 16xyzred
30-04-2016Q2 16xyzred
01-05-2016Q2 16xyzred
29-10-2016Q4 16xyzGreen
30-10-2016Q4 16xyzGreen
31-10-2016Q4 16mnoGreen
01-11-2016Q4 16mnoGreen
02-11-2016Q4 16mnoGreen

Thanks in Advance.

1 Reply
Kushal_Chawda

Data:

LOAD Date,

     Quarter,

     [Primary Key]

FROM

[Data1.xlsx]

(ooxml, embedded labels, table is Sheet1);

Count:

LOAD Quarter,

     Count([Primary Key]) as Countkey

Resident Data

Group by Quarter

Order by Quarter;

Left Join(Data)

LOAD *,

     if(RowNo()=1 or Countkey<Previous(Countkey),'Green','Red') as Staus

Resident Count;

DROP Table Count;