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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to group data into json file

I have data that i want to group based on a field , and the other fields into arrays. exemple this table:

Produit

Brand

A

Toyota

B

Toyota

C

Renault

D

Toyota

 

I want in the result a json file like that:

{

  {Brand:"Toyota", Produit:["A","B","D"]},

  {Brand:"Renault", Produit:["C"]}

}

Could some one help me please

Labels (3)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

Hello 

 

{

  {Brand:"Toyota", Produit:["A","B","D"]},

  {Brand:"Renault", Produit:["C"]}

}

 

is not correct json . check on https://jsonlint.com/

 

it should be like this :

{ "Data" :

[

 {Brand:"Toyota", Produit:["A","B","D"]},  {Brand:"Renault", Produit:["C"]}

]

}

 

Let me know your opinion.

 

View solution in original post

5 Replies
akumar2301
Specialist II
Specialist II

you have 1st sort the input with Brand Name 

 

then tWritetoJSON 

 

0683p000009M4ag.jpg

 

Output

 

{"Brand":"Toyota","Product":["A","B","D"]}

{"Brand":"Renault","Product":["C"]}

Anonymous
Not applicable
Author

i get just one element per table, this is the result obtained:

 

 {Brand:"Renault", Produit:"C"},

 {Brand:"Toyota", Produit:"A"},

 {Brand:"Toyota", Produit:"B"},

 {Brand:"Toyota", Produit:"D"}

}

akumar2301
Specialist II
Specialist II

0683p000009M4oH.jpg

Anonymous
Not applicable
Author

Does not work 

akumar2301
Specialist II
Specialist II

Hello 

 

{

  {Brand:"Toyota", Produit:["A","B","D"]},

  {Brand:"Renault", Produit:["C"]}

}

 

is not correct json . check on https://jsonlint.com/

 

it should be like this :

{ "Data" :

[

 {Brand:"Toyota", Produit:["A","B","D"]},  {Brand:"Renault", Produit:["C"]}

]

}

 

Let me know your opinion.