Combine columns except when null (i.e., skip null)
Hi there,
Is there a way to combine values in multiple columns except when the value is null? For example:
This is a small example, I need to combine 8 different columns with a separator without ending up with: cat, , , , , orange, .
I'm essentially looking for a DOMO equivalent of TEXTJOIN() in Excel. The values don't always inform each other i.e., the sixth column may not be null while the third column may be null.
Thank you in advance!
Best Answers
-
My solution is kind of a work-around but the basic idea is to use a delimiter to combine the columns and remove them later on:
- Add a comma (or another delimiter) to the end of each text column that need to be combined (e.g., cat --> cat,)
- Combine the columns (will look something like cat,dog,,,bird,,)
- Replace text LIKE ',,%' with ','
- Replace ',' (or comma no space) with ', ' (or comma with space)
- Remove last char
1 -
you could also try a formula tile to combine:
CASE WHEN `column A` IS NULL THEN `column B` WHEN `column B` IS NULL THEN `column A` ELSE CONCAT(`column A`, ', ', `column B`) END
... Sorry, just re-read your entire post and I noticed that you are combining 8 fields.
CONCAT(CASE WHEN `column A` is NULL then '' else concat(`column A`,', ') end, CASE WHEN `column B` is NULL then '' else concat(`column B`,', ') end, CASE WHEN `column C` is NULL then '' else concat(`column C`,', ') end, CASE WHEN `column D` is NULL then '' else concat(`column D`,', ') end, CASE WHEN `column E` is NULL then '' else concat(`column E`,', ') end, CASE WHEN `column F` is NULL then '' else concat(`column F`,', ') end, CASE WHEN `column G` is NULL then '' else concat(`column G`,', ') end, CASE WHEN `column H` is NULL then '' else concat(`column H`,', ') end )
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman3
Answers
-
Hi @tlammie1806, an option that could get it closer to your desired state is using CONCAT function, to combine data, as well as a RegEx (e.g. /s), to remove any blank/white spaces. Unfortunately, there isn't an equivalent of TEXTJOIN in Domo currently
0 -
My solution is kind of a work-around but the basic idea is to use a delimiter to combine the columns and remove them later on:
- Add a comma (or another delimiter) to the end of each text column that need to be combined (e.g., cat --> cat,)
- Combine the columns (will look something like cat,dog,,,bird,,)
- Replace text LIKE ',,%' with ','
- Replace ',' (or comma no space) with ', ' (or comma with space)
- Remove last char
1 -
you could also try a formula tile to combine:
CASE WHEN `column A` IS NULL THEN `column B` WHEN `column B` IS NULL THEN `column A` ELSE CONCAT(`column A`, ', ', `column B`) END
... Sorry, just re-read your entire post and I noticed that you are combining 8 fields.
CONCAT(CASE WHEN `column A` is NULL then '' else concat(`column A`,', ') end, CASE WHEN `column B` is NULL then '' else concat(`column B`,', ') end, CASE WHEN `column C` is NULL then '' else concat(`column C`,', ') end, CASE WHEN `column D` is NULL then '' else concat(`column D`,', ') end, CASE WHEN `column E` is NULL then '' else concat(`column E`,', ') end, CASE WHEN `column F` is NULL then '' else concat(`column F`,', ') end, CASE WHEN `column G` is NULL then '' else concat(`column G`,', ') end, CASE WHEN `column H` is NULL then '' else concat(`column H`,', ') end )
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman3
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
- 738 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