Skip to main content
Question

DIfference between the same field in a table from the two most recent entries

  • December 27, 2023
  • 0 replies
  • 311 views

Forum|alt.badge.img

Hi! My title is incorrect above and I can't seem to edit it-whoops! I am trying to set up a formula field that finds the difference between two fields in two separate entries (for the same customer) and for the two most recent entries only. For example, Entry A field X from 01/01/2022 is 98.72; Y is 50. Entry B field X from 09/06/2023 is 200. This formula field would calculate the difference (always a positive value) between B and A (X-Y) and record 150 in field Y in Entry B. Then, Entry C field X added on 10/24/2024 is 700; the difference between Entry C  X field and Entry B (most recent) Y field is recorded in field Y in Entry C...and so on always focusing on the two most recent entries by Read Date.

I have attached a screenshot of how I would like it to function; I have manually entered the data in this example. Is this possible? Or something similar?

Thank You!



------------------------------
Jill Jackson
------------------------------

This topic has been closed for replies.

Forum|alt.badge.img+20
  • Registered
  • December 27, 2023

Will you always have a set number of entries, or a relatively small max number of entries? If you have say, 5 entries max or less, you could do it with a number of summary fields. ie:

Summary Field 1: Most Recent Value from where = Entry A
Summary Filed 2: Most Recent Value from where = Entry B

You would do this for the max number you would have, then look them down to the children and have a formula field that does your calculation (If Entry B, then value + Most Recent value A)

However, if you want this to run for any number of entries, I think the only way is with formula queries. I have done something just like this, but I am careful using the values on reports, as the query can stall things out and make it pretty slow. If you can get away with a small number of summary and lookup fields, I recommend that direction, otherwise you are forced into formula queries.

I can help with the query if that is the direction you need to go.



------------------------------
Mike Tamoush
------------------------------

Forum|alt.badge.img
  • Author
  • Registered
  • June 10, 2024

Mike and Chayce,

Yes- I would like to implement the solution provided by Chayce if it is indeed simpler. The more simple, less upkeep, the better at this stage in my QB learning. Would either or both of you be willing to help implement this in to our system? I did put it in a help ticket, prior to your solution, and they responded that they could not help with it. If so, how would you like to communicate-Teams? 

Also, just to clarify- I would be importing 1-2 historic entries(child) through a csv. Here is an example of how this will look:    Each entry is linked to a Customer record(parent) through a field relationship

1st entry with date of 5/5/23 > 2nd entry with date of 5/5/24 (both of these through the import) > 3rd entry with date of 10/5/24 will be manually entered into the app by staff; and it continues, in theory, in sequence by manual entry.

There may be a need to add that "formula query hack" you mentioned Chayce in response to Mike's catch of the possible out of sequence addition. 

Thank you again for your help and hope to hear from you soon!


Forum|alt.badge.img+20
  • Registered
  • June 11, 2024

I'll re-read this when I have time but I know my schedule is swamped. However, if you have a small budget MarkShnier__You is a FANTASTIC consultant and can likely help implement any scenario.


Forum|alt.badge.img
  • Author
  • Registered
  • June 11, 2024

Thank you for the recommendation, Mike-I appreciate it!