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
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 747 Beast Mode
- 59 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 396 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 126 Manage
- 123 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 109 Community Announcements
- 4.8K Archive