Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Dynamic pivot table with hierarchy


Does anyone know whether Qlikview supports the ability for dynamic pivot dimensions?

So by this I mean that I have a table which contains parent-child records within the same table


ID     Name     ParentID    Sales

1      Dave       NULL         £50

2      James     1               £100

3      Rob         2               £100

4      Andy       2               £200

5      Don         4               £25

Now, I know that I can load this data structure in using a Hierarchy function, but this will give me a static number of columns. I will not the depth of the recursion at run time so I can't possibly know how many columns I'm going to have. Does Qlikview provide anyway to recursively load this list in and set up a pivot table with the Name field so that it doesn't need to know the names of the columns up front?

Tags (2)
1 Reply

Re: Dynamic pivot table with hierarchy

No, Qlikview has no way to know at load time which fields (of all loaded fields) you want in a particular pivot table. The easiest way around this is to create an empty table with enough fields so your data will always fit. Then load your data and apply the hierarchy function and append the resulting data to the empty table that was created earlier.

Another way could be use the Depth parameter with the Hierarchy function, find the maximum depth value and store it in a variable. Then you could create a macro that creates a pivot table with all the necessary fields using the value in the variable as a counter for a loop that adds the fields to the pivot table. If you want to try that, you're on your own

talk is cheap, supply exceeds demand
Community Browser