Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have some questions on Qlikview's load script.
My dataset looks like this :
<brands>
<brand>
<id>brand1</id>
<name>Brand 1</name>
<categories>
<jeans>4</jeans>
</categories>
</brand>
<brand>
<id>brand2</id>
<name>Brand 2</name>
<categories>
<coats>2</coats>
<parkas>1</parkas>
<shorts>1</shorts>
</categories>
</brand>
</brands>
The results I want should look like this :
Name | Category |
---|---|
Brand 1 | Jeans |
Brand 2 | Coats |
Brand 2 | Parkas |
Brand 2 | Shorts |
As you can see the problem is that the category names are tag names and that there are unlimited number of elements under the <categories> tag.
How can I get the tag name from an element and how can I link it to the brand name ?
It is possible to do that in the Load script ?
Thank you,
anita mazur
How about this (test.xml is just your data as given in your question).
// Start of [test.xml] LOAD statements
brand:
LOAD id,
name,
[categories/jeans] as jeans,
[categories/coats] as coats,
[categories/parkas] as parkas,
[categories/shorts] as shorts
FROM [test.xml] (XmlSimple, Table is [brands/brand]);
// End of [test.xml] LOAD statements
tCategory:
Crosstable(Category, value, 2)
LOAD
*
RESIDENT
brand
;
Category:
LOAD
id
,Category
,value
RESIDENT
tCategory
WHERE value > 0;
DROP TABLE tCategory;
Thank you very much. it works !