Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a Flag

  T1:  

IdNameStatusRiskDate
100ABCOpenLow10/1/2014
100ABCClosedMedium3/2/2014
200DEFOpenLow1/1/2015
200DEFOpenMedium1/2/2015
200DEFClosedHigh1/3/2015
300XXXOpenHigh5/6/2015
300XXXOpenLow7/7/2015
300XXXClosedHigh8/9/2015
400YYYOpenLow1/2/2015
400YYYClosedMedium2/2/2015
500ZZZOpenLow2/3/2015
100ABCClosedHigh3/5/2014
100ABCClosedMedium3/3/2014
200DEFClosedLow1/4/2015

I have a Table T1 with above mentioned data

we need to show the Risk  for a Id changes from when we first receive the Id's risk  in the above table to when their Status changes to Closed

A flag needs to be added to know risk changes or not

Output:

   

IdNameStatusRiskDateRisk_Flag
100ABCOpenLow10/1/2014N
100ABCOpenMedium3/2/2014Y
100ABCOpenHigh3/5/2014Y
100ABCClosedMedium3/6/2014Y
200DEFOpenLow1/1/2015N
200DEFOpenMedium1/2/2015Y
200DEFOpenHigh1/3/2015Y
200DEFClosedLow1/4/2015Y
300XXXOpenHigh5/6/2015N
300XXXOpenLow7/7/2015Y
300XXXClosedHigh8/9/2015Y
400YYYOpenLow1/2/2015N
400YYYClosedMedium2/2/2015Y
500ZZZOpenLow2/3/2015N

Please help me to get the above output.

31 Replies
Not applicable
Author

No it is not working for the same logic as dates have been changed

Kushal_Chawda

what would be the expected output for this

aniketsr
Creator
Creator

kush141087‌ your logic is working perfectly according to the requirement.

Kushal_Chawda

Or just do order by ID

Not applicable
Author

Data:

   

IdNameStatusRiskDate
100ABCOpenLow10/1/2014
100ABCOpenMedium-
200DEFOpenLow1/1/2015
200DEFOpenMedium1/1/2015
200DEFOpenHigh1/1/2015
300XXXOpenHigh5/6/2015
300XXXOpenLow5/6/2015
300XXXClosedHigh8/9/2015
400YYYOpenLow1/2/2015
400YYYClosedLow2/2/2015
500ZZZOpenLow2/3/2015
100ABCOpenHigh10/1/2014
100ABCClosedMedium3/6/2014
200DEFClosedLow1/4/2015

Result:

   

IdNameStatusRiskDateRisk_Flag
100ABCOpenLow10/1/2014N
100ABCOpenMedium-Y
100ABCOpenHigh10/1/2014Y
100ABCClosedMedium3/6/2014Y
200DEFOpenLow1/1/2015N
200DEFOpenMedium1/1/2015Y
200DEFOpenHigh1/1/2015Y
200DEFClosedLow1/4/2015Y
300XXXOpenHigh5/6/2015N
300XXXOpenLow5/6/2015Y
300XXXClosedHigh8/9/2015Y
400YYYOpenLow1/2/2015N
400YYYClosedLow2/2/2015N
500ZZZOpenLow2/3/2015N
Kushal_Chawda

What output you are getting using the logic I have suggested.. can you show?

sunny_talwar

Kush this

Capture.PNG

sunny_talwar

Try this:

Table:

LOAD Id,

     Name,

     Status,

     Risk,

     Date,

     AutoNumber(RowNo(), Id) as Key

FROM

[https://community.qlik.com/thread/216412]

(html, codepage is 1252, embedded labels, table is @17);

FinalTable:

LOAD *,

  If(Id = Peek('Id'), If(Risk <> Peek('Risk'), 'Y', 'N'), 'N') as Risk_Flag

Resident Table

Order By Id, Key;

DROP Table Table;


Capture.PNG

Kushal_Chawda

see this

Data:

LOAD Id,

    Name,

    Status,

    Risk,

    Date,

    RecNo() as Rec

FROM

[https://community.qlik.com/thread/216412]

(html, codepage is 1252, embedded labels, table is @17);

Final:

LOAD Id,

    Rec,

    if(Id <> previous(Id) or  (Id = previous(Id) and Risk= previous(Risk)),'N','Y') as Risk_Flag,

    Name,

    Status,

    Risk,

    Date

Resident Data

order by Id,Rec;


Not applicable
Author

   

IDFixedStatusTest_DatevaluesDate
100Napproved8/8/2016Text8/8/2016
200Napproved26/05/2016Text126/05/2016
300Napproved27/05/2016Text127/05/2016
400Napproved10/10/2016Text110/10/2016
500NReject10/12/2016Text410/12/2016
500YReject10/12/2016Text410/13/2016

three bar charts can be displayed on below 3 conditions

1)Where Status = approved

Fixed = 'N'

today date is greater than the Test_Date-60   (bar chart)

2)Where status = approved

Fixed = 'N'

today date is is greater than the Test_Date  (bar chart)


3)Where Satus = Reject

Match where the role has Text4 (bar chart)
Could you please help on above three set expressions.