Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Calculate the earliest date (field B) a number (field A) was exceeded

Featured Replies

Say for example I had 100,000 employees who all make widgets every day. I have a record for each employee's productivity on each day. If Bob has worked 10,000 days, I have 10,000 records for Bob. Field A is the number of widgets and Field B is the date. I want to add a field to each record that calculates the earliest date where the employee made as many or more than the number of widgets he made on that day. If Bob made 200 widgets on 1/1/2020, and the first time time he ever made at least 200 widgets in a day was 5/5/2018, then I want a field that shows 5/5/2018 in his record for 1/1/2020.

I know I can write a looping script that searches for Bob records with >=200 and sorts it by date and then sets a variable for the date in the first record, goes back to the original record, and sets the new field with the variable. I'm dealing with tens of millions of records though and it could take weeks for a script to fill all that in. This is what I've been doing and it's taking nearly a whole second to process each record.

Of course, I assume there's ways to do this with related tables, possibly a self join. I haven't figured it out yet.

2 hours ago, databaser said:

I want to add a field to each record that calculates the earliest date where the employee made as many or more than the number of widgets he made on that day.

The simplest method to do this would be to construct a self-join relationship of the (let's call it) Productivity table as:

Productivity::EmployeeID = Productivity 2::EmployeeID 
AND
Productivity::Date > Productivity 2::Date 
AND
Productivity::Quantity ≤ Productivity 2::Quantity 

and show the date from the first related record in Productivity 2.

However, with "tens of millions of records" this would probably be quite unusable, unless you were looking at one record at a time (and maybe even then). A more practical method would lookup the date, using the same relationship. And you would need to spend the time required to populate the existing records using relookup.

 

 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.