Waterfall chart with annual values at each end and variances as waterfall steps
I'm trying to create a waterfall chart, where the first bar in the waterfall is the absolute value for 2017, and the steps in the waterfall are the variances in each category. This should result in the summary bar being the absolute value for 2018.
My best solution so far is to create a new category for values in 2017, however, this means that the values in 2017 are unavailable for the variance calculation for each category.
Has anyone done this previously, or is there another way to create the 2017 bar at the start of the waterfall?
I've illustrated this problem in the attached excel file. Columns B, C and D are my dataset, and E to J are my beast mode columns/calculations. I have 6 categories A to F, and I create a new category G for 2017 values, so that G is the first bar in my waterfall, with an absolute value for 2017. However, to calculate the variance of categories A to F, for the steps in the waterfall, the rows in 2017 are now in the G category, and unavailable to categories A to F.
Best Answer
-
We had to set this up via a data flow. But we have accomplished a graph similar to this. We were looking at a rolling 6 month vs 6 month variance in our waterfall.
Here are the steps we used to set up the graph:
1.) Create a table called current_6_months
SELECT
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN '(Not Assigned)' ELSE `Salesforce Account ID` END AS `Salesforce Account ID`
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END AS `Product Family`
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END AS `Product Group`
,SUM(a.`Sales at constant Exchange Rate`) `Sales`FROM sales_with_account_segment_and_rollup a
WHERE a.`Date of Invoice` >= DATE_SUB(CURDATE(),INTERVAL 6 MONTH)
GROUP BY
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN 'Undefined' ELSE `Salesforce Account ID` END
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END2.) Create a table called prior_6_months
SELECT
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN 'Undefined' ELSE `Salesforce Account ID` END AS `Salesforce Account ID`
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END AS `Product Family`
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END AS `Product Group`
,SUM(a.`Sales at constant Exchange Rate`) `Sales`FROM sales_with_account_segment_and_rollup a
WHERE a.`Date of Invoice` >= DATE_SUB(CURDATE(),INTERVAL 12 MONTH)
AND a.`Date of Invoice` < DATE_SUB(CURDATE(),INTERVAL 6 MONTH)GROUP BY
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN 'Undefined' ELSE `Salesforce Account ID` END
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END3.) Union the two tables (we called this full_union)
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,SUM(Sales_Cur_6_Month) Sales_Cur_6_Month
,SUM(Sales_Prior_6_Month) Sales_Prior_6_MonthFROM (
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,`Sales` Sales_Cur_6_Month
, 0 Sales_Prior_6_Month
FROM current_6_months
UNION ALL
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,0 Sales_Cur_6_Month
,`Sales` Sales_Prior_6_Month
FROM prior_6_months
) a
GROUP BY
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`4.) Identify New Vs Lost business (we labeled this table new_business)
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,SUM(Sales_Prior_6_Month) Sales_Prior_6_Month
,SUM(Sales_Cur_6_Month) Sales_Cur_6_Month
,CASE
WHEN SUM(Sales_Cur_6_Month) > SUM(Sales_Prior_6_Month) AND SUM(Sales_Prior_6_Month) = 0 THEN 'New Business'
WHEN SUM(Sales_Cur_6_Month) < SUM(Sales_Prior_6_Month) AND SUM(Sales_Cur_6_Month) = 0 THEN 'Lost Business'
END `New vs Lost Business`FROM full_union
GROUP BY
`Account Name`
,`Salesforce Account ID`
,`Product Family`5.) Create different Scenarios that you want to track with waterfall (create_scenarios)
SELECT
a.*
,CASE
WHEN b.`New vs Lost Business` IS NOT NULL THEN b.`New vs Lost Business`
WHEN a.Sales_Cur_6_Month > a.Sales_Prior_6_Month AND a.Sales_Prior_6_Month = 0 THEN 'Menu Expansion'
WHEN a.Sales_Cur_6_Month <= a.Sales_Prior_6_Month AND a.Sales_Cur_6_Month = 0 THEN 'Menu Attrition'
WHEN a.Sales_Cur_6_Month > a.Sales_Prior_6_Month THEN 'Organic Growth'
WHEN a.Sales_Cur_6_Month <= a.Sales_Prior_6_Month THEN 'Organic Attrition'
END AS Scenario
,a.Sales_Cur_6_Month - a.Sales_Prior_6_Month as `Amount Change from Prior 6 Months`FROM full_union a
LEFT JOIN new_business b
ON a.`Account Name` = b.`Account Name`
AND a.`Salesforce Account ID` = b.`Salesforce Account ID`
AND a.`Product Family` = b.`Product Family`WHERE CASE WHEN IFNULL(a.Sales_Cur_6_Month,0) = 0 AND IFNULL(a.Sales_Prior_6_Month,0) = 0 THEN 'T' ELSE 'F' END = 'F'
ORDER BY `Account Name`, `Product Family`
6.) Union Growth and Attrition (union_growth_and_attrition)
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,`Scenario`
,`Amount Change from Prior 6 Months` as `Waterfall Amount`
,`Amount Change from Prior 6 Months`
,Sales_Cur_6_Month
,Sales_Prior_6_MonthFROM create_scenarios
UNION ALL
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,'12-6 Months' `Scenario`
,`Sales` as `Waterfall Amount`
,0 `Amount Change from Prior 6 Months`
,0 Sales_Cur_6_Month
,0 Sales_Prior_6_MonthFROM prior_6_months
This will give you a data set that you can use to create your waterfall.
We created two beastmodes to help with the graph:
"Amt | Waterfall" was used at the VALUE field:
SUM(CASE
WHEN `Scenario` != 'Last 6 Months'
THEN `Waterfall Amount`
END)"Waterfall Sort" was used for SORTING:
CASE
WHEN `Scenario` = '12-6 Months' THEN 1
WHEN `Scenario` = 'Organic Growth' THEN 2
WHEN `Scenario` = 'Menu Expansion' THEN 3
WHEN `Scenario` = 'New Business' THEN 4
WHEN `Scenario` = 'Lost Business' THEN 5
WHEN `Scenario` = 'Menu Attrition' THEN 6
WHEN `Scenario` = 'Organic Attrition' THEN 7
ELSE 8
ENDYou then use `Scenario` as the SUMMARY GROUP and `Scenario` as ITEM NAMES
4
Answers
-
We had to set this up via a data flow. But we have accomplished a graph similar to this. We were looking at a rolling 6 month vs 6 month variance in our waterfall.
Here are the steps we used to set up the graph:
1.) Create a table called current_6_months
SELECT
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN '(Not Assigned)' ELSE `Salesforce Account ID` END AS `Salesforce Account ID`
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END AS `Product Family`
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END AS `Product Group`
,SUM(a.`Sales at constant Exchange Rate`) `Sales`FROM sales_with_account_segment_and_rollup a
WHERE a.`Date of Invoice` >= DATE_SUB(CURDATE(),INTERVAL 6 MONTH)
GROUP BY
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN 'Undefined' ELSE `Salesforce Account ID` END
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END2.) Create a table called prior_6_months
SELECT
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN 'Undefined' ELSE `Salesforce Account ID` END AS `Salesforce Account ID`
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END AS `Product Family`
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END AS `Product Group`
,SUM(a.`Sales at constant Exchange Rate`) `Sales`FROM sales_with_account_segment_and_rollup a
WHERE a.`Date of Invoice` >= DATE_SUB(CURDATE(),INTERVAL 12 MONTH)
AND a.`Date of Invoice` < DATE_SUB(CURDATE(),INTERVAL 6 MONTH)GROUP BY
a.`Account Name`
,CASE WHEN `Salesforce Account ID` IS NULL THEN 'Undefined' ELSE `Salesforce Account ID` END
,CASE WHEN a.`Product Family` IS NULL THEN '(Not Assigned)' ELSE a.`Product Family` END
,CASE WHEN a.`Product Group` IS NULL THEN '(Not Assigned)' ELSE a.`Product Group` END3.) Union the two tables (we called this full_union)
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,SUM(Sales_Cur_6_Month) Sales_Cur_6_Month
,SUM(Sales_Prior_6_Month) Sales_Prior_6_MonthFROM (
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,`Sales` Sales_Cur_6_Month
, 0 Sales_Prior_6_Month
FROM current_6_months
UNION ALL
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,0 Sales_Cur_6_Month
,`Sales` Sales_Prior_6_Month
FROM prior_6_months
) a
GROUP BY
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`4.) Identify New Vs Lost business (we labeled this table new_business)
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,SUM(Sales_Prior_6_Month) Sales_Prior_6_Month
,SUM(Sales_Cur_6_Month) Sales_Cur_6_Month
,CASE
WHEN SUM(Sales_Cur_6_Month) > SUM(Sales_Prior_6_Month) AND SUM(Sales_Prior_6_Month) = 0 THEN 'New Business'
WHEN SUM(Sales_Cur_6_Month) < SUM(Sales_Prior_6_Month) AND SUM(Sales_Cur_6_Month) = 0 THEN 'Lost Business'
END `New vs Lost Business`FROM full_union
GROUP BY
`Account Name`
,`Salesforce Account ID`
,`Product Family`5.) Create different Scenarios that you want to track with waterfall (create_scenarios)
SELECT
a.*
,CASE
WHEN b.`New vs Lost Business` IS NOT NULL THEN b.`New vs Lost Business`
WHEN a.Sales_Cur_6_Month > a.Sales_Prior_6_Month AND a.Sales_Prior_6_Month = 0 THEN 'Menu Expansion'
WHEN a.Sales_Cur_6_Month <= a.Sales_Prior_6_Month AND a.Sales_Cur_6_Month = 0 THEN 'Menu Attrition'
WHEN a.Sales_Cur_6_Month > a.Sales_Prior_6_Month THEN 'Organic Growth'
WHEN a.Sales_Cur_6_Month <= a.Sales_Prior_6_Month THEN 'Organic Attrition'
END AS Scenario
,a.Sales_Cur_6_Month - a.Sales_Prior_6_Month as `Amount Change from Prior 6 Months`FROM full_union a
LEFT JOIN new_business b
ON a.`Account Name` = b.`Account Name`
AND a.`Salesforce Account ID` = b.`Salesforce Account ID`
AND a.`Product Family` = b.`Product Family`WHERE CASE WHEN IFNULL(a.Sales_Cur_6_Month,0) = 0 AND IFNULL(a.Sales_Prior_6_Month,0) = 0 THEN 'T' ELSE 'F' END = 'F'
ORDER BY `Account Name`, `Product Family`
6.) Union Growth and Attrition (union_growth_and_attrition)
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,`Scenario`
,`Amount Change from Prior 6 Months` as `Waterfall Amount`
,`Amount Change from Prior 6 Months`
,Sales_Cur_6_Month
,Sales_Prior_6_MonthFROM create_scenarios
UNION ALL
SELECT
`Account Name`
,`Salesforce Account ID`
,`Product Family`
,`Product Group`
,'12-6 Months' `Scenario`
,`Sales` as `Waterfall Amount`
,0 `Amount Change from Prior 6 Months`
,0 Sales_Cur_6_Month
,0 Sales_Prior_6_MonthFROM prior_6_months
This will give you a data set that you can use to create your waterfall.
We created two beastmodes to help with the graph:
"Amt | Waterfall" was used at the VALUE field:
SUM(CASE
WHEN `Scenario` != 'Last 6 Months'
THEN `Waterfall Amount`
END)"Waterfall Sort" was used for SORTING:
CASE
WHEN `Scenario` = '12-6 Months' THEN 1
WHEN `Scenario` = 'Organic Growth' THEN 2
WHEN `Scenario` = 'Menu Expansion' THEN 3
WHEN `Scenario` = 'New Business' THEN 4
WHEN `Scenario` = 'Lost Business' THEN 5
WHEN `Scenario` = 'Menu Attrition' THEN 6
WHEN `Scenario` = 'Organic Attrition' THEN 7
ELSE 8
ENDYou then use `Scenario` as the SUMMARY GROUP and `Scenario` as ITEM NAMES
4 -
I'm not sure if I followed your logic exactly, but I was able to solve this issue with an ETL dataflow. I filtered my data into 2017 and 2018, then split the 2017 data into two copies, where one copy is used for the 2017 bar of the waterfall, and the second copy is combined with the 2018 data to calculate the variances of each item.0
-
I was trying to do the same thing and found this post. It worked as advertised. It was pretty easy to adapt to my use case. For anyone interested in finding New business, Lost business, Expansion, and Contraction of sales over a period of time this is a useful example. Thanks for sharing
1 -
@ST_-Superman-_ I wanted to let you know I found this thread, followed your example, and was able to implement a Customer Churn page in my instance of Domo based on what you provided here.
HUGE THANK YOU!
2 -
Good stuff, glad I could help.
1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 744 Beast Mode
- 58 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
- 395 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 6 Software Integrations
- 125 Manage
- 122 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