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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Looping through sub fields

i have 3 subfolders in a directory path

C\test

in test there are folder1-prj,folder2-prj,folder3-prj

now i want to loop through these folders and run the following script

EXPRESSIONDATA:

Load

%Key_Data_7EB7522AE0A7D03B

as

ExpressionID,FilePath() as NameID

,

[ExpressionVisual/Label/v]

as

ExpressionName

,

[ExpressionData/Definition/v]

as

ExpressionCalc

,

[ExpressionVisual/Label/v]

&': ' &[ExpressionData/Definition/v]

as

Expression

,

REPLACE

(REPLACE

('$(File)','$(SubDirectory)',''),'.xml','') as

ObjectID

FROM

[$(File)] (XmlSimple

, Table

is

[GraphProperties/Expressions/ArrayOfMainExpressionData/MainExpressionData/Data]);

CHARTDATA:

Load

[ChartProperties/Title/Title/v]

as

ChartTitle

,

[Dimensions/ChartDimensionDataDef/PseudoDef/Name]

as

DimensionCalc

,

[TableProperties/ExpansionInfo/ExpansionData/Pos/DimName]

as

DimensionName

,

REPLACE

(REPLACE

('$(File)','$(SubDirectory)',''),'.xml','') as

ObjectID

FROM

[$(File)] (XmlSimple

, Table

is

[GraphProperties]);

next

left

join

(CHARTDATA) load

ObjectID

,replace

(ObjectID

, 'CH','') as

CHTID

, concat

(distinct

DimensionCalc

) as

DimensionsConcat

REsident

CHARTDATA group

by

ObjectID

;

left

join

(EXPRESSIONDATA) load

ObjectID

,

concat

(distinct

Expression

,'

' ) as

ExpressionsConcat

REsident

EXPRESSIONDATA group

by

ObjectID

;

if i run it in one of the subfolders it works well but i want to be able to loop through all the subfolders

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can find code to (recursively) loop through subdirectories here: loop through to load all files from a folder and its subfolders? You will want to replace the load code from the example with your code.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
giakoum
Partner - Master II
Partner - Master II

not sure what your problem is.

Why don't you use a for next statement to loop through all sub folders?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can find code to (recursively) loop through subdirectories here: loop through to load all files from a folder and its subfolders? You will want to replace the load code from the example with your code.


talk is cheap, supply exceeds demand