Skip 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 based on a first and last record of a found set

Featured Replies

I am quite comfortable in programming in SAS. SAS has a first and last function, I wonder if FileMakerPro has something similar.

 

CustomerID, InvoiceNo, ItemNo

1001   5525   1001

1001   5525   1004

1001   5525   1007

1098   5526   2001

2001   5527   3501

 

Expected result is :

 

 

CustomerID, InvoiceNo, ItemNo, CostItem

1001   5525   1001   25$

1001   5525   1004   10$

1001   5525   1007   10$

1098   5526   2001   25$

2001   5527   3501   25$

 

 

Given the above table I would like to know if this is possible to do the following calculation in FileMaker Pro.

 

Set verifID to concatenate(CustomerID & InvoiceNo)

 

Sort on verifID ascending

 

if first.verifID and last.verifID then set Costitem to 25$

else if first.verifID then CostItem to 25$

        else CostItem to 10$

 

After completing I will do a sum calculation using verifID.

 

1001 5525 total = 45.00$

1098 5526 total = 25.00$

2001 5527 total = 25.00$

 

With regards!

Daniel

Solved by comment

Go to solution

It seems that your goal is to calc an Invoice subtotal.

 

Invoice::Subtotal_c = sum ( invoice_LineItems::extension)

 

where

LineItems::extension = Qty * UnitCost

  • Solution

If this is supposed to be based on a found sets of line items, you could probably use something like =

 

Case ( InvoiceNo = GetNthhRecord ( InvoiceNo ; Get (RecordNumber) - 1 ) ; 10 ; 25 )

 

I believe the prices should be stored in fields and records, rather than hard-coded into a calc, though.

 

 

 

Another possibility is to count the items, multiply the sub-summary count by InvoiceNo times 10 and add 15.

  • Author

Thanks for the quick response.

 

In the final calculation the prices will not be hardcoded. The reason it has not been done at the moment is because I want to focus on a look a like first/last function.

 

In the end the customer invoice will a list of all lines with their appropriate CostItem.

 

The multiply the sub-summary count by InvoiceNo times 10 and add 15 would give me the total amount which I will need later on. However, the difficulty I do have at the moment is to calculate the right cost for each of the items.

 

I will look further the GetNthhRecord function.

 

Daniel

  • Author

Many thanks Comment!

 

The result of the GetNthRecord function is exactly what I was looking for.

 

I will try to understand better the combination of the GetNthhRecord ( InvoiceNo ; Get (RecordNumber) - 1 ) functions.

I am still not sure what exactly is being calculated here. I suspect that basing it on the presence and position of an item in the found set may not be robust enough. Why don't you use a relationship to count the invoice's items?

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.