Leather Knight Posted February 5, 2006 Posted February 5, 2006 How do I create a calculation to evaluate the actual time spent on a project. If I start on 01/12/06 at 12:00 and end on 01/13/06 at 12:00 it should show 24:00 but instead it shows 00:00 because the date is not included in the calculation, just time. Any advice??? Thanks
Raybaudi Posted February 5, 2006 Posted February 5, 2006 Hi try this calc, result Time: Timestamp ( dateEnd ; timeEnd ) - Timestamp ( dateStart ; timeStart )
LaRetta Posted February 5, 2006 Posted February 5, 2006 To keep the display from breaking (in case you haven't entered something in every field), it might be a good idea to test first before the calculation evaluates. Something like ... If ( DateStart and DateEnd and TimeStart and TimeEnd ; Timestamp ( DateEnd; TimeEnd) - Timestamp ( DateStart; TimeStart) ) UPDATE: One would think that the checkbox 'Do Not Evaluate if all Referenced Fields are Empty' would stop the calculation but it does not. I believe this is because the calc is straight math in FM's eyes. LaRetta :wink2:
comment Posted February 5, 2006 Posted February 5, 2006 Well, there's a difference between "all referenced fields are empty" and "any of the referenced fields is empty".
LaRetta Posted February 5, 2006 Posted February 5, 2006 (edited) That checkbox responds however (normally stopping the calculation evaluation), if only ONE field (of several referenced) is empty. This is why I believe the wording should be changed on it from 'All' to 'Any'. That is ... unless this behavior has changed in vs. 8. I could be wrong ... I frequently am. But it doesn't effect this calculation in vs. 8.02. If ANY or ALL the fields are empty, the calc either displays ? or displays -17576239:30:00. UPDATE: Okay I was wrong. If ALL fields are empty, and it is unchecked, it won't evaluate. But the reverse is NOT true ... I've had calcs NOT evaluate with one blank field with that checkbox checked. Oh never mind, Michael, this checkbox and I have had a long love/hate relationship ... Always test it. That's the answer. Always test it first. Edited February 5, 2006 by Guest Added Update
comment Posted February 5, 2006 Posted February 5, 2006 (normally stopping the calculation evaluation), if only ONE field (of several referenced) is empty. Can you give an example?
LaRetta Posted February 6, 2006 Posted February 6, 2006 (edited) Here is one such (seemingly) inconsistent example. This calculation appropriately does NOT calculate (because the box is checked 'Do not evaluate if ALL referenced fields are empty' and all fields ARE empty). But if you enter a value in the First Name, it still will REFUSE to evaluate the remaining fields unless I uncheck that box. This is an example of when I feel the wording should be 'if ANY' fields are empty. This thread also displays some of this inconsistent behavior. The checkbox seems illogical and inconsistent (although it's probably just me). Maybe it is only the wording. Or maybe it should just be reversed. But it is certainly confusing ... UPDATE: In the above example, the checkbox would stop eval if all fields were empty but would do nothing to protect if only one field is empty. And, unless ALL fields are filled it, the calc will break. Maybe we just need another checkbox called "Don't evaluate if ANY fields are empty." That would save us from many IsEmpty() tests. ^) LaRetta DoNotEval.zip Edited February 6, 2006 by Guest Added Update
comment Posted February 6, 2006 Posted February 6, 2006 The only inconsistency I see in that thread is between versions. I am under the impression that from v.7 and up it works as expected. The file you have attached is interesting - how am I supposed to know if it evaluates or not?
LaRetta Posted February 6, 2006 Posted February 6, 2006 (edited) If it evaluates, calculation evaluation results will fill in with field labels. They are reps of the same calc. And yes, I was just sitting here reviewing that most of the problems with Do Not Evaluate have happened to me in prior versions. :wink2: Edited February 6, 2006 by Guest
LaRetta Posted February 6, 2006 Posted February 6, 2006 I've pinpointed my thinking on why it feels so illogical. With checkbox checked, no labels should show if there is no field data. That works. With checkbox unchecked, all labels should show no matter what. That also works. BUT, having the checkbox checked should NOT stop the evaluation if one field has data; in fact, the checkbox shouldn't make a difference if checked. Do you see why it feels inconsistent?
comment Posted February 6, 2006 Posted February 6, 2006 I think what happens here is this: for each repetition, there is only one referenced field. If it is empty, it does not evaluate.
LaRetta Posted February 6, 2006 Posted February 6, 2006 (edited) I can work with that logic. Except if I change the FirstName by adding a field MiddleName, then adjusting calc to include TWO fields, it still breaks. Try: Case(Extend(FirstName) = "" and Extend(MiddleName) = ""; "First Name"); With the checkbox checked, and entering something into ANY field, the calc should still evaluate, I would think? I'm sure I'm missing something here yet ... Edited February 6, 2006 by Guest Fixed miswording...
comment Posted February 6, 2006 Posted February 6, 2006 Case(Extend(FirstName) = "" and Extend(MiddleName) = ""; "First Name"); From the point of view of THIS repetition, FirstName and MiddleName are ALL the fields that there are. This is more about how repeating calc fields behave than how the "Do not evaluate" option behaves. See the atached for another example that shows this. DoNotEval.fp7.zip
LaRetta Posted February 6, 2006 Posted February 6, 2006 (edited) Well now - I LIKE this Michael! Just by referencing a field which is never empty (even a global or an ID), we can force a calculation to fire on any field referenced which is empty (in this example). Using a Common field with Do Not Eval may be a handy thing. I may be able to eliminate some IsEmpty() and not IsEmpty() tests or control a calc fire via a Common field. I will play with it ... I will let go of this oddity now but one other comparison? I thought a single rep repetition was just like any other field (and I understand it treats ALL reps as one field and that's why it was breaking). FM should be seeing this just as a standard calc on a standard field. It still breaks with: Choose(Get(CalculationRepetitionNumber) - 1; Case(Extend(FirstName) = "" and Extend(LastName) = ""; "Evaluate") ) Do Not Evaluate checkbox stops the evaluation on a 2-field single calculation. Is this still just because it's a repetition and not a NORMAL field? Thank you so much!! LaRetta Edited February 6, 2006 by Guest
comment Posted February 6, 2006 Posted February 6, 2006 Maybe I am missing something here: I don't see any change in behavior when you wrap the calc in Choose(Get(CalculationRepetitionNumber) - 1;...). It's still looking at the fields it has to evaluate, and if all of them are empty, AND the checkbox is on, it does nothing. What you call breaking, I call working very well. In your original calc, each repetition has a single field to worry about. If that field is empty and the checkbox is on, than that's it. It doesn't care about what the other repetitions have on their plate (and considering that there may be 32,000 of those, that's a good thing!). When I added a field BEFORE the Choose(), it became part of EVERY repetition's evaluation chain - so if that one wasn't empty, ALL repetitions had to evaluate. I didn't think it was of any practical value (much cheaper just to uncheck the box); I just wanted to show the behavior.
Recommended Posts
This topic is 6929 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 accountSign in
Already have an account? Sign in here.
Sign In Now