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.

Need help with calculation

Featured Replies

Gents, need your help on the following issue:

I need to track my expanses. There are 4 tables: Products, PriceChanges, Transactions.

The problem: I need to make a script which will make calculations in transactions tab, accounting for the latest price change.

Example:

01 jan17 I bought one bottle of wine for $1 

03 jan 17 I bought the same bottle of wine for $1,5. So the latest price is $1.5

In Products table there is one record which is wine. 

In PriceChanges table there are two records: $1 and $1.5

I need that Transactions table automatically take corresponding wine prices while adding new or past records.

 

This is not a question about calculation. It is a question about relationships. You need a relationship between Transactions and PriceChanges, based on matching ProductID, and sorted on the PriceChanges side by Date, descending. This will ensure that the latest price is always the first related record in PriceChanges - and you can define the Price field in Transactions to lookup the value using this relationship.

  • Author

Hi, 

thanks for the fast reply. Hmm...I am new user to FM, the solution sounds really confusing at the moment, but I'll try.

I am sorry if I make this even more confusing, but I have just noticed that your original post says:

1 hour ago, stan111 said:

I need that Transactions table automatically take corresponding wine prices while adding new or past records.

To accommodate past records, you will need to base the relationship not only on matching ProductID, but also on:

Transactions::Date ≥ PriceChanges::Date

  • Author

Comment,

I wasn't successful in performing your recommendations. Is it possible to check my file? Thanks.

Untitled Copy.fmp12

See if this works for you (haven't had time to test it myself).

Untitled Copy 2.fmp12

  • Author

Thanks, unfortunately it doesn't work for me :(

 

 

It doesn't work because (a) I forgot to sort the relationship, and (b) you have the wrong Price field in the portal to Transactions. Try it now.

Untitled Copy 3.fmp12

  • Author

you are the man! Thank you!😀

  • Author

Hi Comment, 

I created a dashboard with a bunch of buttons, attached script to every button, which allows me navigating to specific record of the Products table. 

The process of creating a script to every button is a very time consuming as I need to write a script that  a) goes to layout b)finds the certain record 

1 "Step: Go to Layout
    Layout: Products


2 Step: Perform Find" 

 

Is there a way to simplify the task?

 

Thanks!

 

This has nothing to do with your original question. Please start a new thread.

  • Author

I've got a trouble, trying to incorporate additional field  into calculations at Transactions tab. I used CASE function in the formula.

The trick with lookup prices doesn't work now. 

Would you please help me out with that? 

 

Edited by stan111

I will gladly answer any questions you might have - if I find them interesting. I will not debug your file, sorry. Maybe someone else will be able to help you.

Edited by comment

  • Author

that's fine. Let's go that way:

 

1. I have a Price and Item. I need to find Total.

Formula will be: Price * Item

2. I have Price, Item and different Sellers.

Formula will be: Price(of the specific seller)* Item

 

How can I realize this case in FM?

 

 

Sorry, that makes no sense to me. Price is usually an attribute of an item. I don't understand the meaning of Price * Item.

Re #2, If an item is sold by multiple sellers, you will need a join table between Items and Sellers. This table will have an individual record for each Seller/Item combination, with a Price field holding the price of that specific item from that specific seller. There is nothing to calculate here, it's pure data (essentially a price list).

 

 

  • Author

Thanks a bunch!

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.