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.

Calculation Help With Filtered Dates

Featured Replies

I have one table with sales. The person who did the selling, the item and date.

 

While they are entering sales I want a summary of how much they have sold in the past month and past year.

How would I get a calculation to find the sales persons records and filter them by the date range and then add up the amount field?

 

While they are entering sales I want a summary of how much they have sold in the past month and past year.

 

Basic idea is to create two calculation fields, type date: the first is Get ( CurrentDate ) - 30, the second is (you guessed it) Get ( CurrentDate ) - 365. Make sure to set both fields to unstored.

 

Create two relationships from wherever it is the data input happens to the Sales table, where cdMinus30 ≤ Sales::date, and cdMinus365 ≤ Sales::date, respectively.

 

You need to add to each relationship a predicate to only match the records of the current user. Since you don't say if there is a user table, or from which context “they” input the data, and whether the system knows who the currently logged in user is, I can't be more specific.

 

If you don't have a Users table and don't store the current user somewhere, you'd have to implement all of this as a self-relationship between two Sales TOs (since this would be the only place where a User name/ID resides that could do any matching), which mightn't be the best solution. 

 

Then create a summary field in Sales as sTotalAmount. On your data input layout, display this field two times as related field via the two relationships.

 

Note that you could do all of this with two unstored calc fields and ExecuteSQL() calculations that use the same logic as the relationship predicate(s) described above (but you don't need calculated match fields). If you're so inclined, you could even use two Web Viewers and fill them via ExecuteSQL(), which means no schema overhead at all (additional fields, TOs, relationships …)

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.