Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 5798 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

In my schedule table I have a field called 'date' and a field called 'job#.' There are multiple records with the same job# and different dates. I am looking for a calc called 'next_date' to only show the next date beyond the current date for each job# occurrence.

Thanks in advance

Posted

If you have a Job table (and it sounds like it since you have a Job#) then you connect Jobs::Job# = Schedules::Job#. Then sort your schedule table (in the relationship dialog) descending on date. The calculation (result is date) in your Jobs table would then be:

Schedules::Date + 1

However, if you don't have a Jobs table (and that Job# comes from external source) then you can achieve the same thing by a self-join on your Schedules table, joining on Job #. Then treat the new self-join table as described above.

If you do not wish to sort your relationship, you can also use:

Last ( Schedules::Date + 1 ) but ONLY if the records entered in the Schedules table are ALWAYS entered in date order ascending.

LaRetta :wink2:

Posted

Would'nt using the aggregate function Max work better here and alleviate the need to worry about sorts or entry order? Using the self join: Max ( Schedules:Date ) +1?

Posted

Max() would be the LAST option I would use simply because it IS an aggregate, which is precisely why I did not mention it. :wink2:

Posted (edited)

Upon reread, I agree! Thank you, Michael. :smile2:

In that case, I wouldn't mess with the primary Jobs-to-Schedules relationship, leaving it based only on the JobID. Use a NEW relationship ...

Create a calculation (result is date) called Today in Schedules with: Get ( CurrentDate ). Be sure to make it unstored in Options. If you think you might want to see other dates (such as ... you forgot to do something for a schedule last week and you would like to pretend that 'today' is last week) then use a global date field for Today instead so you can modify it if needed. You can populate the global in your startup script for normal 'next day' use. Then join:

Schedules::Today < [color:green]SelfJoin Schedules:B:Date

AND

Schedules::JobID = [color:green]SelfJoin Schedules::JobID

You will still need to sort this relationship but this time in ascending order on date (if it isn't in natural date creation order) so you grab the first record past Today. This [color:green]SelfJoin Schedules::Date field can be placed directly on your layout so that, from any job, you will see the next upcoming scheduled date.

Edited by Guest

This topic is 5798 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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