Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
DeeptiRao
Contributor II
Contributor II

CrossTable query

Hi All,

I have data in below format 

NameAddress
AABC
AXYZ
ADEF
BJKL
BOPQ
CABC
DXYZ
EDEF
FJKL
FOPQ
FABC

 and the result should be in below format. So basically getting all the values for first column together.

ABCDEF
ABCJKLABCXYZDEFJKL
XYZOPQ   OPQ
DEF    ABC

I tried using cross table, but the result is not correct.

Kindly help to resolve this issue.

 

Labels (1)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

I missunderstood your requirement. I had a second look and attaching a suggested solution (using your previous attached i/p excel file). 

See my output in the below image.

image.png

CROSS_DATA:
LOAD
	  PS_SERIES, 
	  PS_MATERIAL_TYPE
FROM
	[CROSS_DATA.xlsx]
	(ooxml, embedded labels, table is CROSS_DATA)
;

Data:
LOAD * inline[TMP_ID];
FOR each _serie in fieldvaluelist('PS_SERIES')
	JOIN (Data) 
	LOAD 
		RowNo() as TMP_ID,
		PS_MATERIAL_TYPE as [$(_serie)]
	Resident 
		CROSS_DATA
	WHERE 
		PS_SERIES = '$(_serie)'
	;
NEXT
DROP Table CROSS_DATA; //Do not need this source anymore
DROP FIELD TMP_ID; //Do not need this field 

  

View solution in original post

4 Replies
Vegar
MVP
MVP

You can use Generic Load to solve this problem.

Take a look at @hic  good old blog post named The Generic Load.

54157_Generic%20transformation4

 

-Vegar

DeeptiRao
Contributor II
Contributor II
Author

Hi Vegar,

I tried the solution recommended by you, I am getting the result, but not exactly same. The rows are getting duplicated.

I am attaching the the qvw file, i/p and o/p file.

Kindly help.

Thanks & Regards,

Deepti

Vegar
MVP
MVP

I missunderstood your requirement. I had a second look and attaching a suggested solution (using your previous attached i/p excel file). 

See my output in the below image.

image.png

CROSS_DATA:
LOAD
	  PS_SERIES, 
	  PS_MATERIAL_TYPE
FROM
	[CROSS_DATA.xlsx]
	(ooxml, embedded labels, table is CROSS_DATA)
;

Data:
LOAD * inline[TMP_ID];
FOR each _serie in fieldvaluelist('PS_SERIES')
	JOIN (Data) 
	LOAD 
		RowNo() as TMP_ID,
		PS_MATERIAL_TYPE as [$(_serie)]
	Resident 
		CROSS_DATA
	WHERE 
		PS_SERIES = '$(_serie)'
	;
NEXT
DROP Table CROSS_DATA; //Do not need this source anymore
DROP FIELD TMP_ID; //Do not need this field 

  

DeeptiRao
Contributor II
Contributor II
Author

The solution is working correctly.

Thanks a Lot Vegar.