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.

unusual calc behavior

Featured Replies

I've got a table that has records of stays by individuals at a homeless shelter. Each record has value for an admit date and may or may not have a value for the departure date (if the person hasn't left yet).

I've also got two globals that feed a report. I'm trying to calculate the total number of nights during the two dates in the globals.

Here's the calc:

Let([

today = Get(CurrentDate);

startReport = Report Globals::Start Date;

endReport = Report Globals::End Date;

admit = Individual Admittance::Individual Admission date;

depart = Individual Admittance::Individual Departure Date;

depart = Case(IsEmpty(depart); today; depart);

end = Min(endReport;depart);

start = Max(startReport; admit);

result = end - start

];

result

)

This gives me expected results for records with a depart date. But with no depart date, I'm getting very odd results. I get the correct answer half the time...literally. As an unstored calc, and in the Data Viewer, the result toggles between the correct number of days (end - start) and a different number (admit - start).

It's pretty weird. The results toggle on some records when I click in and out of the record.

I copy and pasted the two tables into a new file and imported the data with similar results, it seems a less common (10% of the time rather than 90%), but still there.

Any thoughts?

Why have you got 2 declarations for "depart" ?

  • Author

Because if the field is null, I want to use the current date. I could have wrapped it all in one declaration, but I find this way clearer to me.

How about a demo showing the problem? I cannot see anything obviously wrong with the calc, but I don't see your relationships, and I'd suspect them first (why aren't admit/depart local fields to begin with?).

  • Author

They two date fields are local, they're just presented with relationships in order to debug.

After opening it this morning, the unstored calc as a field seemed to be working ok, but not the exact same calc in the debugger. Then I closed and restarted again and everything's fine.

I'm in the Twilight Zone.

If I can get the file to replicate the behavior consistently, I'll definitely post it.

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.