How do you calculate a percentage using two different count(distinct) beast mode calculations?
I have a data set that contains the following columns, training id, employee id, training question id (each training contains multiple questions), training completion status (i.e., passed, failed, to do).
We have this beast mode calculation to identify the number of employees that have passed the training:
case when `training completion status` = 'Passed' then count(distinct training id, employee id) end
We have this beast mode calculation to identify the number of total trainings assigned to employees:
count(distinct training id, employee id)
We need to calculate percent of employees who passed the trainings. We have tried the following calculation and it returns nothing:
(case when `training completion status` = 'Passed' then count(distinct training id,employee id) end )/(count(distinct training id, employee id))
Unfortunately, we cannot use an ETL to summarize the data at the training employee level prior to building the card.
Thanks in advance
Best Answers
-
@D_Markley34 The main issue appears to be due to the syntax of your distinct counts. The Count function only expects one argument, so it does not know how to interpret the Training ID and Employee ID within the count. In order to take a distinct count of a combination of values from multiple columns, you will need to concatenate them together into a single string value like this:
COUNT(DISTINCT CONCAT(`Training ID`,`Employee ID`))
Secondarily, you will also likely encounter problems due to having an aggregate function inside your case statement because it causes granularity issues. You can get around this by wrapping the count around the entire case statement. Your final percentage should look like this:
COUNT(DISTINCT case when `training completion status` = 'Complete' then CONCAT(`Training ID`,`Employee ID`) end)/COUNT(DISTINCT CONCAT(`Training ID`,`Employee ID`))
0 -
Thanks MichelleH that works.
0
Answers
-
@D_Markley34 The main issue appears to be due to the syntax of your distinct counts. The Count function only expects one argument, so it does not know how to interpret the Training ID and Employee ID within the count. In order to take a distinct count of a combination of values from multiple columns, you will need to concatenate them together into a single string value like this:
COUNT(DISTINCT CONCAT(`Training ID`,`Employee ID`))
Secondarily, you will also likely encounter problems due to having an aggregate function inside your case statement because it causes granularity issues. You can get around this by wrapping the count around the entire case statement. Your final percentage should look like this:
COUNT(DISTINCT case when `training completion status` = 'Complete' then CONCAT(`Training ID`,`Employee ID`) end)/COUNT(DISTINCT CONCAT(`Training ID`,`Employee ID`))
0 -
Thanks MichelleH that works.
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
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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