Count if
Hello,
I need a separate count of 4 specific values in 6 columns. I believe I can get one of the counts, but am not sure how to get all 4 values counted.
Formula for one of the values:
COUNT(CASE
WHEN `Item Status 1-4` = 'Active'
THEN COUNT('Item Status')
END)
After I get the values of each status, I need to get them into a chart , which I believe can do. I can probably just repeat the formula for each status, and each column, but that seems repetitive and I hope there is an easier way to accomplish this.
I can get this done in Excel but am having trouble with finding the correct way in Domo.
Any ideas out there?
Answers
-
Have you tried using a pivot table card and putting the Item Status 1-4 in your row field, your date field in the columns field and then your Item Status field in the values field and choose the aggregation type of Count?
Based on your Excel screenshot, that should work. If this doesn't work, if you can provide what your source data looks like, that would help.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1 -
Alternatively you can utilize an ETL to do the pivot for you as well.
Assuming your data is in the format of:
Date | Item Status | Count Field
you can utilize a group by field and group by Date and Item Status taking the SUM of the count field (or alternatively if you have the raw data do a Count of that field). then toss that into a Pivot table tile to pivot your data into an output dataset.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Hello,
Thank you both for the answers. I think the pivot table will be easiest for me to execute. I will flag the ETL as something I need to research and learn about.
Data looks like this:
The Item Status column is the status of items on 1/4/21 - and needs to be included in the total evaluation. The pivot table wont allow me to have the Item Status 1/4 as a row and as a column.
In Excel I can define the values by just typing them into a cell, and then referencing those cells for the value to count. How would I define the values for Domo to count similar to Excel?
This is what my attempt at the Domo pivot table looks like:
the data is not counting as Excel. Any thoughts or direction would be greatly appreciated.
0 -
Are you sorting the table by any fields? Sorting can cause Domo pivot tables to "drop" data. Would you mind showing the sort properties as well?
1 -
I do not have any sorting set in analyzer.
There are two filters, but removing them does not impact the issue. It only adds more items to each status across all status columns.
0 -
couple things here.
1) restructure your data.
For maximum flexibility and recycleability you want the structure
[item no], [Date], [Status], [Count Status]
If you can't see the data at the item level then:
[Date], [Status], [Total Count Status]
You can accomplish this with a Collapse Columns or Dynamic Pivot in Magic ETL. Then you just need to extract the Date from the Column name. You can use Split Column with a custom delimiter " - "
Regarding your inital Beast Mode. It's syntactically incorrect even if it's returning a result.
COUNT(CASE WHEN `Item Status 1-4` = 'Active' THEN COUNT('Item Status') END)
You generally can't have two aggregate functions (count) nested inside each other. Rewrite as:
COUNT( CASE WHEN `Item Status 1-4` = 'Active' THEN 'Item Status' END )
Ideally I would recommend avoiding COUNT unless I'm doing a COUNT DISTINCT and instead favor summing rows.
SUM ( CASE WHEN `Item Status 1-4` = 'Active' THEN 1 END )
The nice thing about this approach is you don't have to ask yourself "does COUNT treat text or numbers differently, what about NULLs in the Status column. etc. It's just ... either you met your CASE condition and therefore returned a 1 or you didn't.
GLHF.
FYI I provide mentoring and implementation services.
Jae Wilson
Check out my π₯ Domo Training YouTube Channel π¨βπ»
**Say "Thanks" by clicking the β€οΈ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1 -
Thank you for the terrific directions and suggestions. I was able to unpivot the data and split the dates into the column 'Status Date'. The ABC column is there because I could not figure out how to only take the 1/04/21 when splitting the original 'Item Status' in the ETL.
Then I took your suggestion to do a Sum instead of a Count for each Status (Active, EOL, Inactive, Inactive1).
Then used beast mode results to create a table. And this is where I am stuck again - how do I get all counts into a similar format as the original excel table? Do I have to add another WHEN condition that would tell the formula when to 'count' the status?
Thank you again for the direction and assistance.
0 -
so put [Staus Date] in columsn.
put [status] in rows
and just do a sum(1) as your metric. (remove the other metrics).
Jae Wilson
Check out my π₯ Domo Training YouTube Channel π¨βπ»
**Say "Thanks" by clicking the β€οΈ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
if you waant the total of all active statuses you need
sum(sum(1)) over () this will give you a grand total for all rows.
if you want a grand total of only active statuses
sum(sum case when Status in ('choice a', choice b' ) then 1 end )) over ()
these are window functions which is a feature you'd need your CSM to enable "window functions in beast modes"
Jae Wilson
Check out my π₯ Domo Training YouTube Channel π¨βπ»
**Say "Thanks" by clicking the β€οΈ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
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
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive