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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
kangaroomac
Partner - Creator II
Partner - Creator II

Create an Array from field values

Good Day,

Has anyone created a field with an array of values?

Below is script that demonstrates what I'm trying to achieve.

The desired output is for [Inner Table] to have the following:

Inner CodeInner Value
1A, B, C
2D, E, F
3G, H, I

[Data_Table]:
load * inline [
Code, Value
1, A
1, B
1, C
2, D
2, E
2, F
3, G
3, H
3, I
];


For Each x in FieldValueList('Code')

    Let vCurrentCode = $(x);
   
    [Outer Table]:
    LOAD
     '$(x)' as "Outer Code"
    AutoGenerate 1;
   
   
    For Each y in FieldValueList('Code')
    
        Let ConcatenatedValue = ConcatenatedValue & ' ' & Peek('Value',y,'Data_Table') & ',';

        [Inner Table]:
              LOAD
              '$(x)' as "Inner Code",
              '$(ConcatenatedValue)' AS "Inner Value"
        AutoGenerate 1
             Where
                   $(x) = $(vCurrentCode);
       
        Let content = Null;
       
    Next y
   
Next x

1 Solution

Accepted Solutions
kangaroomac
Partner - Creator II
Partner - Creator II
Author

Hi Jagan,

SubField would work if I was going the other way.

max dreamer solved it in a QlikView discussion.

For anyone reading this later and wondering what the solution was, you can find it here:

Create array from field values

View solution in original post

3 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try SubField() like this

LOAD

InnerCode,

SubField(InnerValue, ',') AS Value

FROm DataSource;

Regards,

jagan.

kangaroomac
Partner - Creator II
Partner - Creator II
Author

Hi Jagan,

SubField would work if I was going the other way.

max dreamer solved it in a QlikView discussion.

For anyone reading this later and wondering what the solution was, you can find it here:

Create array from field values

jagan
Partner - Champion III
Partner - Champion III

Yes, I read it wrongly, you can do this by using Group by & Concat().

Regards,

jagan.