Help Returning The Value for the Latest Date with value
Good afternoon,
My company reports a monthly census number for each of its Healthcare centers. I compare these numbers to the budget input. Majority of other metrics, like VISITS, NEW PATIENTS or DROPS can be summed for a year to date number, but Census should not be summed as it would report the latest total each month. I am currently using the formula in Beast Mode to calculate the prior month's census without having it summed up:
CASE
WHEN `HCC Census actual` and MONTH(`Date`) = MONTH(ADDDATE(CURDATE(), interval-1 Month)) AND
YEAR(`Date`) = YEAR(ADDDATE(CURDATE(), interval-1 Month)) THEN (`HCC Census actual`)
Else 0
END
The issue with this is usually the prior months financials do not show until 10 days into the next month. For those 10 days prior to the number being reported, there will be no data in the prior month and the census will show as 0.
Need some advice on how to pull the latest census number when not 0 for those days in the month prior to the financials coming in.
Answers
-
If the data always uploads on the 10th day you can offset your current date function by 10 days and nest that as a replacement for curdate()
ADDDATE(CURDATE(), INTERVAL -10 DAY)).
n.b. if it uploads at a certain time you can extend this process to include hours and minutes too.
A more dynamic solution though if you are waiting on someone to send you data and it's approximately 10 days is to wrap your case statement with another case statement acting as a trigger based on the max date of your dataset.
I.e. if the max date in your dataset is not in the last month then use a variation of your above case statement with ADDDATE(CURDATE(), INTERVAL -2 Month)). Once the data is uploaded your max date will be within the last month and that trigger case statement will swap back to your original code and go through the ADDDATE(CURDATE(), INTERVAL -1 Month)) process.
0 -
Thank you Stuck. i like the idea of adding Case statement within a Case statement. Going to play with this logic. appreciate the reply
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.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 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