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.
1
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.
1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive