Is a Case Statement using COUNT / SUM possible?
Good morning. Not sure if it's the case statement itself, i.e. incorrect syntax or if there's an issue related to divide a COUNT by a SUM value. We've also tried to run this as COUNT / COUNT but to no avail.
We'd like to use only certain agents when trying to determine a Completed Conversion % for offers. The beast mode currently used to determine COMPANY WIDE conversion rate is:
CASE
WHEN SUM(`Settled`) = 0 THEN 0
ELSE (SUM(`Completed`)/ SUM(`Settled`))
END
However, when determining the conversion rate for specific agents we'd need to isolate them using the OWNER column, which ties in their name with the COMPLETED column from the beast mode above, but we've come up with this but again it's not validating/working:
CASE (
WHEN COUNT(`Owner` = 'Jane Doe', 'John Doe')
THEN 1 ELSE 0 / SUM(`Settled`)
END)
** we've tried several variations on this as well, even using a single agent name, with no luck in getting it to validate/work
Best Answer
-
Hi,
If I understood correctly your question, this may help:
COUNT(CASE WHEN `Owner` = 'Jane Doe' OR `Owner` = 'John Doe' THEN `Owner` END)
/
NULLIF(SUM(`Settled`),0)
Tell me how it goes.
Ricardo Granada
MajorDomo@Lusiaves
**If the post solves your problem, mark it by clicking on "Accept as Solution"
**You can say "Thank you" by clicking the thumbs up in the post that helped you.2
Answers
-
Hi,
If I understood correctly your question, this may help:
COUNT(CASE WHEN `Owner` = 'Jane Doe' OR `Owner` = 'John Doe' THEN `Owner` END)
/
NULLIF(SUM(`Settled`),0)
Tell me how it goes.
Ricardo Granada
MajorDomo@Lusiaves
**If the post solves your problem, mark it by clicking on "Accept as Solution"
**You can say "Thank you" by clicking the thumbs up in the post that helped you.2 -
@RGranada, sorry for taking so long to respond, and thanks for the quick reply, as always! It didn't work at first but then realized SETTLED is a date field and that it likely couldn't be totaled as a SUM, so we changed it to COUNT and it validated - seems to be working as expected!
0 -
@RGranada, before I do anything further, just wanted to see what we should do to expand upon our original request in this thread? Wasn't sure if we should add that in here, or open a new thread since this was already marked as resolved. Thanks in advance!
0 -
@John-Peddle feel free to go ahead and open a new topic if you have questions around something else. That will help make your new request searchable for someone else if they have the same question later, as well as increasing visibilty for others to respond.
1
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.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 36 Predict
- 15 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