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

Previous Function

Hi ,

I want to find previous of monthly value ,but data received on daily basis

     Input

IDMonthYear StatusDate
1234Jul-17Done7/31/2017
1234Aug-17InProgress8/31/2017
1234Sep-17InProgress9/18/2017
1234Sep-17InProgress9/17/2017
1234Sep-17InProgress9/16/2017
1234Sep-17InProgress9/14/2017
1234Sep-17InProgress9/13/2017
1234Sep-17InProgress09/12/2017
1234Sep-17InProgress09/10/2017
1234Sep-17InProgress09/09/2017
1234Sep-17InProgress09/07/2017
1234Sep-17InProgress09/06/2017
1234Sep-17InProgress09/05/2017
1234Sep-17InProgress09/04/2017
1234Sep-17InProgress09/03/2017
1234Sep-17InProgress09/02/2017

Output.Required

   

IDMonthYear StatusCheck
1234Jul-17NoChnage
1234Aug-17Change
1234Sep-17NoChnage
1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Hi,

Temp:
LOAD ID,
MonthName(MonthYear) as MonthYear,Only(Status) as Status,
Max(Date) as Date
FROM
https://community.qlik.com/servlet/JiveServlet/download/1348183-296465/Sample.xlsx
(ooxml, embedded labels, header is 1 lines, table is Sheet1)
Group By ID,MonthYear;
LOAD ID,MonthYear,
If(Status=Previous(Status) or RowNo()=1,'NoChange','Change') as StatusCheck
Resident Temp
Order By ID,MonthYear;
Drop Table
Temp;

Regards,

Antonio

View solution in original post

8 Replies
techvarun
Specialist II
Specialist II

What is the definition of Nochange and Change here?

Anonymous
Not applicable
Author

there is change in status in Aug month from Done to inProgress

Anil_Babu_Samineni

May be this?

LOAD Num(ID) as ID,

    MonthName(MonthYear) as MonthYear,

    Status,

    Date(Date) as Date,

    If(Status = Previous(Status), 'NoChange', 'Change') as StatusCheck

FROM

(ooxml, embedded labels, header is 1 lines, table is Sheet1, filters(

Remove(Row, Pos(Top, 22)),

Remove(Row, Pos(Top, 21)),

Remove(Row, Pos(Top, 20)),

Remove(Row, Pos(Top, 19)),

Remove(Row, Pos(Top, 18))

));

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
antoniotiman
Master III
Master III

Hi,

Temp:
LOAD ID,
MonthName(MonthYear) as MonthYear,Only(Status) as Status,
Max(Date) as Date
FROM
https://community.qlik.com/servlet/JiveServlet/download/1348183-296465/Sample.xlsx
(ooxml, embedded labels, header is 1 lines, table is Sheet1)
Group By ID,MonthYear;
LOAD ID,MonthYear,
If(Status=Previous(Status) or RowNo()=1,'NoChange','Change') as StatusCheck
Resident Temp
Order By ID,MonthYear;
Drop Table
Temp;

Regards,

Antonio

Anil_Babu_Samineni

If you need first row as "No Change" you could try this?

     If(Status = Previous(Status) or RowNo() = 1, 'NoChange', 'Change') as StatusCheck

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

why u have used only function

antoniotiman
Master III
Master III

Because Group By clause needs aggregation function like Only(),Min(),Max(),Avg() atc.

Anonymous
Not applicable
Author

Thanks