Sholly Posted June 3, 2010 Posted June 3, 2010 Is there something like an opposite version of the "Last" function that will find the FIRST non-empty record? I am trying to calculate the time between my first record (with an associated timestamp) and my last record (with an associated timestamp.
bruceR Posted June 3, 2010 Posted June 3, 2010 None required. Any time you get a related field you are always getting the first value - as defined by the sort order of the relationship. Set variable [ $first; LineItems::ProductID] Set variable [ $last; Last(LineItems::ProductID) ]
comment Posted June 3, 2010 Posted June 3, 2010 A reference to a related field returns the value from the first related RECORD - not necessarily the first VALUE: if the field happens to be empty in the first record, the reference will return empty too. The exact opposite of the Last() function, i.e. one that returns the first non-empty value, would be = GetValue ( List ( Related::Field ) ; 1 )
bruceR Posted June 3, 2010 Posted June 3, 2010 Well, I do think it is important for the OP to understand the details of how this works, and consider whether he want the first non-empty value (which could the 13th value) ; or the true first value - empty. If in fact that is the result of the data contents and relation sort order.
comment Posted June 3, 2010 Posted June 3, 2010 Yes, I believe a simple reference may suffice in this case, as it doesn't seem likely that the value will be ever empty. I only added the clarification because the OP specifically asked for value from "the FIRST non-empty record".
Sholly Posted June 3, 2010 Author Posted June 3, 2010 Yes, I am looking for the first non-empty value, as defined by the sort order.
Sholly Posted June 3, 2010 Author Posted June 3, 2010 Hmm, the "GetValue..." solution isn't working. I currently have the calc below, but it isn't giving me a real number for everything because it is finding the first value, and not the first NON-EMPTY value. And for some, the first value is empty. (Last (Behavior to Follow by Date ID#:Timestamp_Begin) - ( Behavior to Follow by Date ID#::Timestamp_Begin ))/60 When I change it to incorporate comment's solution I get unusable values for all records. My adjusted calc that doesn't seem to work at all looks like this: (Last(Behavior to Follow by Date ID#::Timestamp_Begin) - GetValue(List(Behavior to Follow by Date ID#::Timestamp_Begin) ; 1))/60
comment Posted June 3, 2010 Posted June 3, 2010 Try = ( Last ( Behavior to Follow by Date ID#:Timestamp_Begin ) - GetAsTimestamp ( GetValue ( List ( Behavior to Follow by Date ID#::Timestamp_Begin ) ; 1 ) ) ) / 60
Sholly Posted June 3, 2010 Author Posted June 3, 2010 Once again, you have solved my problem. It worked like a charm. Thanks!
Recommended Posts
This topic is 5628 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