Transforming an array of custom fields
I have a dataset currently flowing in from MongoDB which is essentially populated based on custom fields that are optionally set within the source. Each element in the array has the name and value of the custom field (ie. customField<0-N>_fieldName and customField<0-N>_fieldValue). The issue is that it's not always the same column for the same field as
we use this as an array of custom fields, and not as specific fields for specific custom fields.
To make it simpler for a user to find all custom fields with certain key, I am trying to add columns in the ETL to pull in values for a specific custom field, if it exists. As an example, add a column for Member_Info_Verified
. This follows a conditional value to check customField<0-N>_fieldName == 'Member_Info_Verified'
and if so, set the value tocustomField<0-N>_fieldValue
, otherwise leave empty.
Attaching a few screenshots of the various types of rows I see for Name/Value combinations. Type can be ignored. Open to any sort of advice whether it be using a combination of formula tiles or running a Python script.
Best Answer
-
I did this in a magic ETL. My initial dataset looked like this:
I then ran the following steps in Magic ETL
- Dynamic Unpivot. This is used to stack all of your columns on top of each other.
- field number. I create two fields in this step. One to identify the id, request, and column number; and one to designate the field type (field name or value)
- Filters for FieldType. This allows me to join the field values to the field names in the next step.
- Join Data.
- Select Columns.
- Pivot. This takes the stacked values and allows me to return them to one row per ID. The key here is that you will need to call out each of the column names that you are wanting to create. If your field names change frequently, this will require a lot of maintenance.
- Output Dataset.
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman1
Answers
-
If I am understanding your question correctly, you could use a single formula tile in Magic ETL with a series of case statements to create new fields. To recreate the logic you posted above would be:
CASE WHEN `customField<0-N>_fieldName` = 'Member_Info_Verified' THEN `customField<0-N>_fieldValue` END
You would name this formula something like "Member Info Verified" and then it would appear as a column within your dataset.
If I solved your problem, please select "yes" above
0 -
I did this in a magic ETL. My initial dataset looked like this:
I then ran the following steps in Magic ETL
- Dynamic Unpivot. This is used to stack all of your columns on top of each other.
- field number. I create two fields in this step. One to identify the id, request, and column number; and one to designate the field type (field name or value)
- Filters for FieldType. This allows me to join the field values to the field names in the next step.
- Join Data.
- Select Columns.
- Pivot. This takes the stacked values and allows me to return them to one row per ID. The key here is that you will need to call out each of the column names that you are wanting to create. If your field names change frequently, this will require a lot of maintenance.
- Output Dataset.
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 737 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive