Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

JSON Dynamically Mapping

Masond3
8 - Asteroid

HI All, 

Need some help 

I am getting the following JSON Response. 

 

JSON_NameJSON_ValueString
data.findCompanyByCompanyId.companyIdCDM001
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeFCA
data.findCompanyByCompanyId.companyIdentifiers.0.idValue295268
data.findCompanyByCompanyId.companyIdentifiers.1.idTypeCAS
data.findCompanyByCompanyId.companyIdentifiers.1.idValue78047108
data.findCompanyByCompanyId.companyIdCDM002
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeLEI
data.findCompanyByCompanyId.companyIdentifiers.0.idValue5493002O03IRC3O7AT88
data.findCompanyByCompanyId.companyIdCDM003
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeNAICS
data.findCompanyByCompanyId.companyIdentifiers.0.idValue99999
data.findCompanyByCompanyId.companyIdCDM004
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeFCA
data.findCompanyByCompanyId.companyIdentifiers.0.idValue079679

 

AIM - For every Company ID there might be referential Ids associated.

Every companyIdentifiers.0.idType represents the Name of the referential ID (ie, Naics, Lei, FCA, CasID), the IDvalue represents the value of the Referential ID

 

NB : At the moment idType are the only 4 values, however there are plans to bring in two new values in the next coming months. 

What i would like help with is, is there a way to dynamically identify the name in the idType and create a column Dynamically, and then put the corresponding idValue in the IDType against the corresponding companyId

 

Expected outcome 

 

companyIdFCA CAS LEI NAICS
CDM00129526878047108  
CDM002  5493002O03IRC3O7AT88 
CDM003   99999
CDM004079679   

 

Looking forward to your response 

 

Many thanks 

Masond3

5 REPLIES 5
binuacs
21 - Polaris

@Masond3 One way of doing this

image.png

Masond3
8 - Asteroid

@binuacs  Thank you for your swift response

I have updated the post to include the header names of "Json_Name" and "JSON_ValueString" This represents F1 & F2 as your headers in the input file. 

I have noticed whilst exploring the additional "JSON_Name" (F1) i have a row called "data.findCompanyByCompanyId.addresses.0.addressId" which also houses a CDM ID . (Example Value CDMA111

 

Looking at your Multi row formula "IIF(STartsWith([F2],'CDM'),[F2],[Row-1:CMD])" i can see that we are creating a new column called "CMD" and we assigning a new ID, anytime you find the Word "CDM" in columnd f2. 

Given that we potentially have an address id which also has CDM ID in the columns F2, is there any possibility to reference column f1 (Json Name) and anytime it mentions  "data.findCompanyByCompanyId.companyId" assign a new CMDID ? 


binuacs
21 - Polaris

@Masond3 Can you provide the input file with the above said data and expected output?

Masond3
8 - Asteroid

@binuacs 
Here is an example of the input as you can see data.findCompanyByCompanyId.companyId and data.findCompanyByCompanyId.addresses.1.addressId both contain "CDM" Within the JSON_ValueString. That's why i was thinking everytime Json_Name says "data.findCompanyByCompanyId.companyId then we can assign a new CMD

 

i have attached  my attempt at the flow based on your initial flow  

 

JSON_NameJSON_ValueString
data.findCompanyByCompanyId.companyIdCDM001
data.findCompanyByCompanyId.addresses.1.addressIdCDMA1111
data.findCompanyByCompanyId.addresses.1.street2 RIVERSIDE BANCHORY KINCARDINESHIRE
data.findCompanyByCompanyId.addresses.1.cityUNITED KINGDOM
data.findCompanyByCompanyId.addresses.1.state 
data.findCompanyByCompanyId.addresses.1.zipcodeAB316PS
data.findCompanyByCompanyId.addresses.1.countryGB
data.findCompanyByCompanyId.addresses.1.countryCdGB
data.findCompanyByCompanyId.addresses.1.regionEMEA
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeFCA
data.findCompanyByCompanyId.companyIdentifiers.0.idValue295268
data.findCompanyByCompanyId.companyIdentifiers.1.idTypeCAS
data.findCompanyByCompanyId.companyIdentifiers.1.idValue78047108
data.findCompanyByCompanyId.companyIdCDM002
data.findCompanyByCompanyId.addresses.1.addressIdCDMA1112
data.findCompanyByCompanyId.addresses.1.street60 Victoria Embankment
data.findCompanyByCompanyId.addresses.1.cityLondon
data.findCompanyByCompanyId.addresses.1.state 
data.findCompanyByCompanyId.addresses.1.zipcodeec1 1nz
data.findCompanyByCompanyId.addresses.1.countryGB
data.findCompanyByCompanyId.addresses.1.countryCdGB
data.findCompanyByCompanyId.addresses.1.regionEMEA
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeLEI
data.findCompanyByCompanyId.companyIdentifiers.0.idValue5493002O03IRC3O7AT88
data.findCompanyByCompanyId.companyIdCDM003
data.findCompanyByCompanyId.addresses.1.addressIdCDMA1113
data.findCompanyByCompanyId.addresses.1.street999 Nike Avenue
data.findCompanyByCompanyId.addresses.1.city 
data.findCompanyByCompanyId.addresses.1.state 
data.findCompanyByCompanyId.addresses.1.zipcode 
data.findCompanyByCompanyId.addresses.1.countryGB
data.findCompanyByCompanyId.addresses.1.countryCdGB
data.findCompanyByCompanyId.addresses.1.regionEMEA
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeNAICS
data.findCompanyByCompanyId.companyIdentifiers.0.idValue99999
data.findCompanyByCompanyId.companyIdCDM004
data.findCompanyByCompanyId.addresses.1.addressIdCDMA1114
data.findCompanyByCompanyId.addresses.1.street123 High Street
data.findCompanyByCompanyId.addresses.1.city 
data.findCompanyByCompanyId.addresses.1.stateWest Midlanda
data.findCompanyByCompanyId.addresses.1.zipcodeCV15NR
data.findCompanyByCompanyId.addresses.1.countryGB
data.findCompanyByCompanyId.addresses.1.countryCdGB
data.findCompanyByCompanyId.addresses.1.regionEMEA
data.findCompanyByCompanyId.companyIdentifiers.0.idTypeFCA
data.findCompanyByCompanyId.companyIdentifiers.0.idValue79679

 

 

Expected out come 

 

companyIdFCA CAS LEI NAICSaddressIdstreetcitystatezipcodecountrycountryCdregion
CDM00129526878047108  CDMA11112 RIVERSIDE BANCHORY KINCARDINESHIREUNITED KINGDOM AB316PSGBGBEMEA
CDM002  5493002O03IRC3O7AT88 CDMA111260 Victoria EmbankmentLondon ec1 1nzGBGBEMEA
CDM003   99999CDMA1113999 Nike Avenue   GBGBEMEA
CDM00479679   CDMA1114123 High Street West MidlandaCV15NRGBGBEMEA

 

 

 

 

binuacs
21 - Polaris

@Masond3 Updated workflow attached

image.png

Labels
Top Solution Authors