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

Count

Hi All,

I have below data 

StatusOpen DateClosed Date
Closed4/9/20194/25/2019
Closed2/22/20192/22/2019
New2/21/2019 
Closed4/28/20195/1/2019

 

 Please help me to achieve below in Qlikview using  if([Closed Date] contains null or [Closed Date] is > the monthend)  and [Open Date] is <= monthend ,1,0)

StatusOpen DateClosed Date1/31/20192/28/20193/31/20194/30/2019
Closed4/9/20194/25/20190000
Closed2/22/20192/22/20190000
New2/21/2019 0111
Closed4/28/20195/1/20190001
    112

 

Thanks In advance

1 Solution

Accepted Solutions
sunny_talwar

Something like this could work... but can take a lot of toll on your script

Test:
LOAD Status,
	 Date([Open Date]) as [Open Date],
	 Date([Closed Date]) as [Closed Date],
	 Date(If(Len(Trim([Closed Date])) > 0, [Closed Date], Today())) as [Closed Date New];
LOAD * INLINE [
    Status, Open Date, Closed Date
    Closed, 4/9/2019, 4/25/2019
    Closed, 2/22/2019, 2/22/2019
    New, 2/21/2019
    Closed, 4/28/2019, 5/1/2019
];

Left Join (Test)
LOAD MonthStart(MinDate, IterNo()-1) as MonthStart,
	 Date(Floor(MonthEnd(MonthStart(MinDate, IterNo()-1)))) as MonthEnd
While MonthStart(MinDate, IterNo()-1) <= MaxDate;
LOAD MonthStart(Min([Open Date])) as MinDate,
	 MonthStart(Max([Closed Date New])) as MaxDate
Resident Test;

FinalTable:
LOAD *,
	 If([Closed Date New] > MonthEnd and [Open Date] < MonthEnd, 1, 0) as Open
Resident Test;

DROP Table Test;

View solution in original post

9 Replies
priya945
Creator
Creator
Author

Could someone hint me to get above requirement in qV

sunny_talwar

Where is the monthend field coming from?

priya945
Creator
Creator
Author

Thanks Sunny for your time.

"monthend" is derived field contains lastdate of the each month.  

1/31/20192/28/20193/31/20194/30/2019

 

sunny_talwar

But where is this field created? in the script? And also you are looking to do this in the script, right?

priya945
Creator
Creator
Author

Yes, want to create this field in the script 

priya945
Creator
Creator
Author

Trying to create the field in script as below and use the Open in UI expression as count(Open). But not getting expected o/p

Test:
load *,
if(([Closed Date1] ='' or [Closed Date1] > Tempdate )and [Open Date1] <= Tempdate ,1,0) as Open

;

LOAD *,

Date(MonthEnd([Closed Date])) as Tempdate,
Date([Open Date]) as [Open Date1],
Date([Closed Date]) as [Closed Date1]
;

Load * Inline [

Status, Open Date, Closed Date
Closed, 4/9/2019, 4/25/2019
Closed, 2/22/2019, 2/22/2019
New, 2/21/2019,
Closed, 4/28/2019, 5/1/2019

];

sunny_talwar

Something like this could work... but can take a lot of toll on your script

Test:
LOAD Status,
	 Date([Open Date]) as [Open Date],
	 Date([Closed Date]) as [Closed Date],
	 Date(If(Len(Trim([Closed Date])) > 0, [Closed Date], Today())) as [Closed Date New];
LOAD * INLINE [
    Status, Open Date, Closed Date
    Closed, 4/9/2019, 4/25/2019
    Closed, 2/22/2019, 2/22/2019
    New, 2/21/2019
    Closed, 4/28/2019, 5/1/2019
];

Left Join (Test)
LOAD MonthStart(MinDate, IterNo()-1) as MonthStart,
	 Date(Floor(MonthEnd(MonthStart(MinDate, IterNo()-1)))) as MonthEnd
While MonthStart(MinDate, IterNo()-1) <= MaxDate;
LOAD MonthStart(Min([Open Date])) as MinDate,
	 MonthStart(Max([Closed Date New])) as MaxDate
Resident Test;

FinalTable:
LOAD *,
	 If([Closed Date New] > MonthEnd and [Open Date] < MonthEnd, 1, 0) as Open
Resident Test;

DROP Table Test;
priya945
Creator
Creator
Author

Thanks Sunny, doing  date left join with main table worked.

sunny_talwar

Super