Sum of multiple filtered values

Hi,
I am trying to create a % by taking a filtered value in Column A and dividing it by other, multiple filters in Column A. I am able to create the numerator, however, when creating the denominator, I can't get it to register more than one filter. I've tried 'AND' and 'OR' statements, but no avail. See below:
SUM(CASE
WHEN Material Description
= 'SALT FLUX-57.5/37.5/5'THEN Quantities Reverse
ELSE 0
END)
/
(SUM(CASE
WHEN Material Description
= 'CLASS I 3004 BODY STOCK SCRAP' OR '3104/3204' THEN Quantities Reverse
ELSE 0) +
(CASE WHEN Material Description
= '3XXX RSI(DROSS)' THEN Quantities Reverse
ELSE 0) +
(CASE WHEN Material Description
= '3003 CLEAR/BARE' THEN Quantities Reverse
ELSE 0))
END
As stated, the denominator only registers the first case ('CLASS I 3004 BODY STOCK SCRAP' OR '3104/3204' in this case). Any advice on how to group the denominator filters?
Also, I tried creating dynamic segments for each of these and did, but don't know if I can reference dynamic segments in formulas. I tried but got not result.
Best Answers
-
@ConstelliumShawn It looks like your first CASE statement was the only one grouped inside the SUM. Rather than using separate CASE statements for each value of Material Description, you can structure your denominator to use a single CASE statement with each condition separated by WHEN… THEN… like this:
SUM(CASE WHEN `Material Description` = 'CLASS I 3004 BODY STOCK SCRAP' THEN `Quantities Reverse` WHEN `Material Description` = '3104/3204' THEN `Quantities Reverse` WHEN `Material Description` = '3XXX RSI(DROSS)' THEN `Quantities Reverse` WHEN `Material Description` = '3003 CLEAR/BARE' THEN `Quantities Reverse` ELSE 0 END)
Alternatively, you can use the IN operator to make a single condition like this:
SUM(CASE WHEN Material Description in ('CLASS I 3004 BODY STOCK SCRAP','3104/3204','3XXX RSI(DROSS)','3003 CLEAR/BARE') THEN Quantities Reverse ELSE 0 END)
0 -
I agree with Michelle's suggestion. I'd also point out that in your original syntax, you are missing multiple END statements. Every time you use CASE, you need to have a matching END. You have 2 CASEs with no ENDs.
**Check out my Domo Tips & Tricks Videos
**Make sure toany users posts that helped you.
**Please mark as accepted the ones who solved your issue.1
Answers
-
@ConstelliumShawn It looks like your first CASE statement was the only one grouped inside the SUM. Rather than using separate CASE statements for each value of Material Description, you can structure your denominator to use a single CASE statement with each condition separated by WHEN… THEN… like this:
SUM(CASE WHEN `Material Description` = 'CLASS I 3004 BODY STOCK SCRAP' THEN `Quantities Reverse` WHEN `Material Description` = '3104/3204' THEN `Quantities Reverse` WHEN `Material Description` = '3XXX RSI(DROSS)' THEN `Quantities Reverse` WHEN `Material Description` = '3003 CLEAR/BARE' THEN `Quantities Reverse` ELSE 0 END)
Alternatively, you can use the IN operator to make a single condition like this:
SUM(CASE WHEN Material Description in ('CLASS I 3004 BODY STOCK SCRAP','3104/3204','3XXX RSI(DROSS)','3003 CLEAR/BARE') THEN Quantities Reverse ELSE 0 END)
0 -
I agree with Michelle's suggestion. I'd also point out that in your original syntax, you are missing multiple END statements. Every time you use CASE, you need to have a matching END. You have 2 CASEs with no ENDs.
**Check out my Domo Tips & Tricks Videos
**Make sure toany users posts that helped you.
**Please mark as accepted the ones who solved your issue.1
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 306 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 788 Beast Mode
- 78 App Studio
- 43 Variables
- 744 Automate
- 187 Apps
- 474 APIs & Domo Developer
- 67 Workflows
- 16 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive