Calculating the Running Maximum
Is there some way to calculate a running maximum either through ETL/SQL?
I have employee hiring data and I want to check if an employee newly hired into a position is a backfill or a new growth. This classification is part of others that are used in existing charts showing how many active/hired/job change/terminations employees we have each month. My strategy at the moment is the calculate the count of employees in each position each month. I want to use this count in finding the running maximum which I will compare to the current count to determine if it a new position or a backfill position.
I'm open to hearing other strategies to approach this problem as well.
Comments
-
Hi @Crisocir
You can utilize a windowing function to calculate the rolling maximum.
MAX(MAX(`JDL Count`)) OVER(ORDER BY `Batch Date`)
Window functions in analyzer require a feature switch. Talk to your CSM if you don't already have them enabled in your instance.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
@Crisocir be super careful with the aggregate functions particularly MAX() and COUNT(DISTINCT) OVER ...
they will work for ONE card with an axis but as soon as you change the axis it'll probably yield the wrong result.
So, while you may get the 'right number' when you look at MAX(MAX()) by Department and Year, if you wanted to do a summary of just MAX(MAX()) by Year (across all departments) or MAX(MAX()) by Region, you'll get the 'wrong result' because of how Window functions work and calculate.
I know that sounds vague, but window functions are complex and if you've never worked with them before they do have a lot of caveats. I did a long form webinar on the topic here. https://www.youtube.com/watch?v=eifSYZIcPzg&t=2247s
Your best bet is to avoid aggregating the data and instead try to capture your data at the POSITION level (not employee) where your granularity is one row per month per position. Then add an 'isNewHire' flag to capture if it's the first month an employee was with the company, and an 'isNewPosition' flag for if a new position was created.
If you have to use window functions, you can use sum(sum()) of the binary flags, and that will ALWAYS give the 'right answer'.
Hope that helps.
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
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