Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
priyasawant
Creator II
Creator II

Split single row of date in to multiple row in a range

  • I have dates present in one row wan to split the dates in multiple rows 

ReqClosedDate.PNG

1 Solution

Accepted Solutions
mr_janne
Contributor III
Contributor III

How about like this:

Input data table "data.csv":

Untitled.jpg

Load Script:

Data:
LOAD 
	if(left(@1,1)=',',right(@1,len(@1)-1),@1) as String,
	if(SubStringCount(if(left(@1,1)=',',right(@1,len(@1)-1),@1),',')=0,1,SubStringCount(if(left(@1,1)=',',right(@1,len(@1)-1),@1),',')+1) as CountOfString,
	len(@1) as LenOfString
FROM
[D:\Qlikview\Data\data.csv]
(txt, codepage is 1252, no labels, delimiter is '\t', msq);

Max:
load
	max(CountOfString) as MaxColumns
resident Data;

let vMaxColumn = peek('MaxColumns',0,'Max');

set vConcat = ;

For ind=1 to $(vMaxColumn) step 1

	$(vConcat)
	OneColumn:
	load subfield(String,',',$(ind)) as ColumnData
	resident Data
	;
	
	set vConcat = concatenate(OneColumn);

next

 

It will output something like this:

Screenshot.png

View solution in original post

5 Replies
tresesco
MVP
MVP

Use Subfield(). Check here

Syntax:  
SubField(text, delimiter[, field_no ]) 
priyasawant
Creator II
Creator II
Author

syntax please

uacg0009
Partner - Specialist
Partner - Specialist

Hi,

Please try below function in back-end

=subfield([Requirement Closed Date],',') as [Requirement Closed Date]

Aiolos Zhao

priyasawant
Creator II
Creator II
Author

So in this scenario it will return 2018-12-04 10:35:07 what about other  date who started with coma (,)

mr_janne
Contributor III
Contributor III

How about like this:

Input data table "data.csv":

Untitled.jpg

Load Script:

Data:
LOAD 
	if(left(@1,1)=',',right(@1,len(@1)-1),@1) as String,
	if(SubStringCount(if(left(@1,1)=',',right(@1,len(@1)-1),@1),',')=0,1,SubStringCount(if(left(@1,1)=',',right(@1,len(@1)-1),@1),',')+1) as CountOfString,
	len(@1) as LenOfString
FROM
[D:\Qlikview\Data\data.csv]
(txt, codepage is 1252, no labels, delimiter is '\t', msq);

Max:
load
	max(CountOfString) as MaxColumns
resident Data;

let vMaxColumn = peek('MaxColumns',0,'Max');

set vConcat = ;

For ind=1 to $(vMaxColumn) step 1

	$(vConcat)
	OneColumn:
	load subfield(String,',',$(ind)) as ColumnData
	resident Data
	;
	
	set vConcat = concatenate(OneColumn);

next

 

It will output something like this:

Screenshot.png