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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Mohan23912391
Contributor
Contributor

Creating Date buckets on single date field

Hi,

I have a date column and value.. I need to create a start date, end date based on that date column and get the below data

  INPUT Data  
  Date(MM.YYYY) Value
  1.2022 100
  2.2022 70
  3.2022 80
  4.2022 80
  5.2022 90
     
     
  OUTPUT Data  
Start date End date Value
1.2022 1.2022 100
2.2022 2.2022 70
3.2022 4.2022 80
5.2022 - 90
     

 

Please help me how can I get this in script ?

Labels (4)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

 

 

raw:
Load monthstart(Date#(Date,'M.YYYY')) as Date,Value Inline [
Date,Value
1.2022,100
2.2022,70
3.2022,80
4.2022,80
5.2022,90
];

temp:
Load *
,if(Value=Peek('Value'),peek('StartDate'),Date) as StartDate
Resident raw
ORder by Date,Value ASC;
drop table raw;


Main:
Load Value,Date(Max(Date)) as EndDate,Date(min(StartDate)) as StartDate Resident temp Group by Value;
Drop table temp;


exit Script;

 

Group by Value  << Ideally you need to be aggregating on an ID field

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

1 Reply
vinieme12
Champion III
Champion III

 

 

raw:
Load monthstart(Date#(Date,'M.YYYY')) as Date,Value Inline [
Date,Value
1.2022,100
2.2022,70
3.2022,80
4.2022,80
5.2022,90
];

temp:
Load *
,if(Value=Peek('Value'),peek('StartDate'),Date) as StartDate
Resident raw
ORder by Date,Value ASC;
drop table raw;


Main:
Load Value,Date(Max(Date)) as EndDate,Date(min(StartDate)) as StartDate Resident temp Group by Value;
Drop table temp;


exit Script;

 

Group by Value  << Ideally you need to be aggregating on an ID field

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.