Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

JSON To Table format

AB
5 - Atom

I am trying to Parse JSON and then convert into the table format 

 

 

I am getting this result after parsing and some cleansing 

 

content.seriesCode0K21
content.seriesNameTuna alba whs ES
content.seriesDescriptionAlbacore tuna
content.currencyNamePound
content.unitNameKilogram
content.frequencyNameDaily
content.countryOfOriginNameNone
content.countryOfDeliveryNameFrance
content.originType0
content.points.0.date25/09/2023
content.points.0.value4
content.points.1.date26/09/2023
content.points.1.value4
content.points.2.date27/09/2023
content.points.2.value4
content.points.3.date28/09/2023
content.points.3.value4
content.points.4.date29/09/2023
code1
content.seriesCodeON28
content.seriesNameAcetic acid cont ddp W Eur
content.seriesDescriptionAcetic acid|
content.currencyNameEuropean Euro
content.unitNameMetric Tonne
content.frequencyNameDaily
content.countryOfOriginNameNone
content.countryOfDeliveryNameWest Europe
content.originType0
content.points.0.date25/09/2023
content.points.0.value1030
content.points.1.date26/09/2023
content.points.1.value1030
content.points.2.date27/09/2023
content.points.2.value1030
content.points.3.date28/09/2023
content.points.3.value1030
content.points.4.date29/09/2023
content.points.4.value1030
code1

 

 

I want to convert it into Table  format like this. Any help would be greatly appreciated! 

 

 

content.seriesCodecontent.seriesNamecontent.seriesDescriptioncontent.currencyNamecontent.unitNamecontent.frequencyNamecontent.countryOfOriginNamecontent.countryOfDeliveryNameDateVALUE
0K21Tuna alba whs ESAlbacore tuna|fresh|wholesale price|Spain||[Thunnus alalunga]PoundKilogramDailyNoneFrance25/09/20234
0K21Tuna alba whs ESAlbacore tuna|fresh|wholesale price|Spain||[Thunnus alalunga]PoundKilogramDailyNoneFrance26/09/20234
0K21Tuna alba whs ESAlbacore tuna|fresh|wholesale price|Spain||[Thunnus alalunga]PoundKilogramDailyNoneFrance27/09/20234
0K21Tuna alba whs ESAlbacore tuna|fresh|wholesale price|Spain||[Thunnus alalunga]PoundKilogramDailyNoneFrance28/09/20234
0K21Tuna alba whs ESAlbacore tuna|fresh|wholesale price|Spain||[Thunnus alalunga]PoundKilogramDailyNoneFrance29/09/20231
ON28Acetic acid cont ddp W EurAcetic acid|monthly contract price|delivered duty paid|West Europe|European EuroMetric TonneDailyNoneWest Europe25/09/20231030
ON28Acetic acid cont ddp W EurAcetic acid|monthly contract price|delivered duty paid|West Europe|European EuroMetric TonneDailyNoneWest Europe26/09/20231030
ON28Acetic acid cont ddp W EurAcetic acid|monthly contract price|delivered duty paid|West Europe|European EuroMetric TonneDailyNoneWest Europe27/09/20231030
ON28Acetic acid cont ddp W EurAcetic acid|monthly contract price|delivered duty paid|West Europe|European EuroMetric TonneDailyNoneWest Europe28/09/20231030
ON28Acetic acid cont ddp W EurAcetic acid|monthly contract price|delivered duty paid|West Europe|European EuroMetric TonneDailyNoneWest Europe29/09/20231030
7 REPLIES 7
OTrieger
12 - Quasar

Columns Tool will do the job. Select horizontally and 19

c.PNG

CoG
14 - Magnetar

I'm not sure how the Make Columns Tool solves this particular problem. The Cross Tab Tool is what jumps to the top of my mind for solving this. The added bit of trickery, however comes in the fact that you do not want to Cross Tab all of the data - the [date/value] fields need to be Cross Tab-ed separately. This, then, requires a multi-step process. We will need to index the dataset to maintain each record appropriately with both RecordID and SubID (See workflow for details), and then bring both datasets back together via Join Tool:

 

Screenshot.png

 

Hope this helps and Happy Solving!

apathetichell
19 - Altair

use multi-row formula to create a primary key (assuming column names are [Name]/[Value]

new text column called Key

 

if [Name]="content.seriesCode" then [Value] else [Row-1:Key] endif --- make this a vstring or something non numeric)

 

new - cross tab - use key as a primary key - name is your column/value is your value. concatenate is your default way to handle duplicate entires. 

 

next use a transpose - > mark all your columns which are not date/values for the date fields as primary keys -> put the dates/values in the fields to be transposed

 

next we are going to use a formula tool:

we will create a new field called entry - which will correspond to the specific sub entity in your json for dates.

I would use:

regex_replace([Name],".*_(\d+)_.*","$1")

 

next you will change [Name] in another formula:

regex_replace([Name],"^(.*)_\d+(.*)","$1$2")

 

this will standardize the [Name] field for the date/value - and drop the number - since you have split this out.

 

Next - back to cross tab.

everything but [Name] and [Value] are your primary keys. - include entry in the keys.

 

name is your column name

value is your value.

concatenated because it makes the most sense.

 

 

I've never used the make columns tool - but I'm not seeing it here. I think with the date/value nesting there's probably some other handling you'd want to do.

OTrieger
12 - Quasar

@CoG 
The make Columns tool solve that easily, instead of all the tools that you were using to get the same result, 1 tool does it all.

bb.PNG

OTrieger
12 - Quasar

This one tool replacing the 9 tools that you were using to get the exact some result.

AB
5 - Atom

would you be able to share your workflow, please can't seem to make it work as you have! Many thanks

apathetichell
19 - Altair

@OTrieger 1) it's not dynamic 2) it doesn't teach a user how to pivot/cross tab data. 3) - 

content.points.0.date25/09/2023
content.points.0.value1030
content.points.1.date26/09/2023
content.points.1.value1030
content.points.2.date27/09/2023
content.points.2.value1030
content.points.3.date28/09/2023
content.points.3.value1030
content.points.4.date29/09/2023
content.points.4.value1030 

 

need to be transposed so that each point is on a seperate line. so no - it's not just one tool.

 

workflow attached.

 

 

Labels
Top Solution Authors