Auto fill column with zero when combining data sets in Data Flow
I have two data sets that I am joining through Data Flow. The data is being joined by SKU and their respective quantities in different locations in our warehouse. Ideally, if the SKU exists in one location and not the other, I need that quantity to populate 0 - not a blank as it currently does. If that doesn't work, is there a way to create a Data Set similar to using VLOOKUP in excel? Thanks, Matt
Comments
-
Matt,
Putting in a default value of 0 if there is not a match is something that can be done in the dataflow using joins and the IFNULL() function. We'll want to simulate a FULL OUTER JOIN by doing a LEFT JOIN and a RIGHT JOIN and then unioning them together. Here's a generic example:
Assume we have two tables, table1 and table2. Each table has two fields: id and value. the following UNION will grab all the values from table1, join them to values from table2 and put in zeros anywhere a null value is found, then do the same thing going the other direction - values from table2 being joined to table1. Unioning the two together gives us the results of both sets.
SELECT
t1.id
, IFNULL(t1.value, 0) AS `Value1`
, IFNULL(t2.value, 0) AS `Value2`FROM
table1 t1
LEFT JOIN table2 t2 ON t1.id = t2.id
UNION
SELECT
t2.id
, IFNULL(t1.value, 0) AS `Value1`
, IFNULL(t2.value, 0) AS `Value2`FROM
table 1 t1
RIGHT JOIN table2 t2 ON t1.id = t2.idSwapping out your tables and values (and adding other fields to the select list as necessary) should let you do the same thing with your data.
Let me know if that helps!
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
- 754 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