Magic ETL Possibility?
Hi, I'm having an issue. I want to split the fruit column by comma then alphabetize, then bring them back together on their respective account ID. How would I do that in magicETL?
Answers
-
There is a new tile in Magic ETL that is currently in Beta that would allow for this and make it MUCH easier. You can reach out to your CSM to see if you can join the beta for it.
Otherwise, you'll have to use a SQL dataflow and do the following:
1. Create a table in a MYSQL dataflow:
SELECTAccount ID
,
CASE
WHEN LENGTH(Fruit
) - LENGTH(REPLACE(Fruit
, ',', '')) + 1 >= 1 THEN SUBSTRING_INDEX(Fruit
, ',', 1)
ELSE NULL
END ASFruit1
,
CASE
WHEN LENGTH(Fruit
) - LENGTH(REPLACE(Fruit
, ',', '')) + 1 >= 2 THEN SUBSTRING_INDEX(SUBSTRING_INDEX(Fruit
, ',', 2), ',', -1)
ELSE NULL
END ASFruit2
,
CASE
WHEN LENGTH(Fruit
) - LENGTH(REPLACE(Fruit
, ',', '')) + 1 >= 3 THEN SUBSTRING_INDEX(SUBSTRING_INDEX(Fruit
, ',', 3), ',', -1)
ELSE NULL
END ASFruit3
,
CASE
WHEN LENGTH(Fruit
) - LENGTH(REPLACE(Fruit
, ',', '')) + 1 >= 4 THEN SUBSTRING_INDEX(SUBSTRING_INDEX(Fruit
, ',', 4), ',', -1)
ELSE NULL
END ASFruit4
,
CASE
WHEN LENGTH(Fruit
) - LENGTH(REPLACE(Fruit
, ',', '')) + 1 >= 5 THEN SUBSTRING_INDEX(SUBSTRING_INDEX(Fruit
, ',', 5), ',', -1)
ELSE NULL
END ASFruit5
FROMmagic_etl_possibility
2. Create a second table in the dataflow:
SELECTAccount ID
,
TRIM(Fruit1
) AS column_value
FROMtransform_data_1
UNION ALL
SELECTAccount ID
,
TRIM(Fruit2
) AS column_value
FROMtransform_data_1
UNION ALL
SELECTAccount ID
,
TRIM(Fruit3
) AS column_value
FROMtransform_data_1
ORDER BY column_value ASC
3. Create the final table:
SELECT
Account ID
,
GROUP_CONCAT(column_value
SEPARATOR ', ') as 'Alphabetized Fruit!'FROM
transform_data_2
GROUP BYAccount ID
4. Behold the final output:
If I solved your problem, please select "yes" above
0 -
@ColemenWilson , awesome thanks for the answer. I’ll give it a try. Also, name of beta tile so I can request?
0 -
No problem! It's called "Order Tile" for Magic ETL.
If I solved your problem, please select "yes" above
0 -
A more straightforward method rather than multiple CASE WHEN statements is to use SPLIT_PART
SPLIT_PART(`Fruit`, ',', 1) -- First in CSV SPLIT_PART(`Fruit`, ',', 2) -- Second in CSV SPLIT_PART(`Fruit`, ',', 3) -- Third in CSV
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2
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
- 627 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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