Beastmode Count help
Hello, I'm looking to create a beast mode to provide a summary number but my case statement counts are not working. The data looks like this:
Message Key Data Source
1 Collected
Delivered
2 Collected
3 Collected
3 Collected
Delivered
Delivered never has a message key but collected could have duplicate message keys. I'd like to say Count distinct meassage key if data source = Collected and SUM that together with count data source if data source = Delivered. The total above would be 5( 2 delivered and 3 unique collected). But I've tried many case statements with sum, with count distinct, count, etc and when I put them in the summary number, it turns up blank. If I add it to a column in a table, the table gives me an error and says it can't be done. This isn't that hard but something is wrong with my data or my beast mode since it's not working. Thanks, Wendi
Best Answer
-
I think that you want to take the count function out of the case statements. Try something like this:
COUNT(DISTINCT CASE WHEN `Data Source`='Collected' THEN `Message Key` END)
+
COUNT(CASE WHEN `Data Source` = 'Delivered' THEN `Data Source` END)
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman0
Answers
-
I think the problem is adding the two cases together. This is what I came up with:
(CASE
when `Data Source` = 'Collected'
then COUNT(DISTINCT `Message Key`)
end)
+
(CASE
when `Data Source` = 'Delivered'
then COUNT(`Data Source`)
end)Both cases work fine separately, but when I add in the " + " operator, the results are blank.
0 -
Yep, that's what I got! Any ideas on how to do this without the case then or other thoughts on adding the cases together. Thanks, Wendi
0 -
I think that you want to take the count function out of the case statements. Try something like this:
COUNT(DISTINCT CASE WHEN `Data Source`='Collected' THEN `Message Key` END)
+
COUNT(CASE WHEN `Data Source` = 'Delivered' THEN `Data Source` END)
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman0 -
I thought I tried all possible combinations of count and sum but I guess not this one because this one worked!!! Thank you, Wendi
0
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
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 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