Beastformula
I have this data with an ID column that are repeated because each unique id have 4 different event type, What I am trying to achieve is if one id with = 4 different category and are all completed in the event status column and within 45days of event date and originalenrollment date then it is completed.
I have this code below but seems not be capturing the statement above,
CASE
WHEN COUNT(DISTINCT ChildPlusID
) =Event Type
IN ('Hearing', 'Vision', 'ASQ3') AND Event Status Code
= 'Completed' AND DATEDIFF(Event Date
, OriginalEnrollmentDate
) <= 45 THEN 'Completed' END
Please help,
Thank you.
Best Answer
-
CASE WHEN COUNT(CASE WHEN `Event Type` IN ('Hearing', 'Vision', 'ASQ3') THEN `ChildPlusID` END) = COUNT( CASE WHEN `Event Type` IN ('Hearing', 'Vision', 'ASQ3') AND `Event Status Code` = 'Completed' AND DATEDIFF(`Event Date`, `OriginalEnrollmentDate`) <= 45 THEN `ChildPlusID` END) THEN 'Completed' END
This is assuming there are 4 records in your dataset with each of the event types. It will count the number of events found in that list and then compare it to the count of the number int the list which are also within 45 days.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Answers
-
CASE WHEN COUNT(CASE WHEN `Event Type` IN ('Hearing', 'Vision', 'ASQ3') THEN `ChildPlusID` END) = COUNT( CASE WHEN `Event Type` IN ('Hearing', 'Vision', 'ASQ3') AND `Event Status Code` = 'Completed' AND DATEDIFF(`Event Date`, `OriginalEnrollmentDate`) <= 45 THEN `ChildPlusID` END) THEN 'Completed' END
This is assuming there are 4 records in your dataset with each of the event types. It will count the number of events found in that list and then compare it to the count of the number int the list which are also within 45 days.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Thank you GrantSmith.
CASE
WHEN
COUNT(
CASE
WHEN
`Event
Type
`
IN
('Hearing', 'Vision', 'ASQ3')
THEN
`ChildPlusID`
END
) = COUNT(
CASE
WHEN
`Event
Type
`
IN
('Hearing', 'Vision', 'ASQ3')
This part is giving syntax error
0 -
Can you post a screenshot of your code and the error your getting?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 308 Workbench
- 7 Cloud Amplifier
- 10 Federated
- 3.8K Transform
- 661 Datasets
- 117 SQL DataFlows
- 2.2K Magic ETL
- 819 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 84 App Studio
- 46 Variables
- 781 Automate
- 193 Apps
- 483 APIs & Domo Developer
- 84 Workflows
- 23 Code Engine
- 43 AI and Machine Learning
- 22 AI Chat
- 3 AI Projects and Models
- 18 Jupyter Workspaces
- 409 Distribute
- 116 Domo Everywhere
- 282 Scheduled Reports
- 11 Software Integrations
- 146 Manage
- 142 Governance & Security
- 8 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 115 Community Announcements
- 4.8K Archive