Case (tableA::fieldA = tableC::fieldA and tableC::fieldG = "x" or "y";
I get the last record matching fieldA, but it is not filtered for x or y.
I think this will make it clear what you have expressed:
tableA::fieldA = tableC::fieldA
tableC::fieldG = "x"
"y" will evaluate to true
Case (tableA::fieldA = tableC::fieldA and ( tableC::fieldG = "x" or tableC::fieldG ="y") ;
Still having trouble with getting the results filtered.
Case ( (c_VehicleAxleT_Position = R_Tires::VAPfk
(R_Tires::Unit = "I" or R_Tires::Unit = "M"
or R_Tires::Unit = "D"))
Last ( R_Tires::TD_Reading)
I get the last reading result, but it will not filter it for I, M or D.
This is running in a portal and I get the correct results for each iteration.
Just won't limit it to the filter.
Thanks in advance,
I think that you need to describe what you are doing in more detail.
”Just won't limit it to the filter." mean?
is this a calculation field or ??
since your calculation references data from a related table there are two details that need to be considered:
Context: from what record and table occurrence does it evaluate from? (A “table occurrence” is a box in the relationship graph. )
if there are multiple related records, as is implied by your use of the last function, the field reference only accesses the value of the first related record.
I have a list of readings from a depth gauge and the values change over time. I am trying to get the latest reading- Last (TD_Reading) to display based on a match to the c_VehicleAxleT_Position. I have been getting a unique value for each match, but I can't get the last reading to be restricted to I, M or D. The reading can also be decoded as a B, P, K or k and would come out with a result. The results are all numbers, but I made it to text fields because I want it to display in 32nds.
The 32nds is about the standard way mechanics are use to looking at the information.
I, M and D are depth measurements.
B, P, K or k are all pressure measurements.
I want to display the results in a portal to each Tire Position.
Maybe there is a better way to do it?
Thanks again for the help.
And is this a calculation field or something else such as a portal filter expression?
Did you try it as all number fields and set calc result to number to see if it works correctly?
If it does you can easily change the result to display as a 'text' in 32nds.
Yes, they are calculation fields.
Reading is parsed calculation from 4 number fields & "/32" to a text field.
The Vehicle, Axle and Tire Position are concatenated calculation field.
VAPfk is a related field in T_Reading Table.
The T_Reading table has a reading of either tire pressure or tread depth, the date of reading, the Tech and the Miles of the reading (Lookup or blank). I want to have the information move by calculation to a portal to show the last Tread Depth reading, the date, the tech and miles, and then show the last tire pressure reading, the date, the tech and miles.
They don't necessarily occur on the same date, but they can.
Currently, I have it displaying the last reading, the date and the tech- I have imported miles yet to have it work.
But it is only showing the last reading what ever it is.
At the beginning of the learning curve, so thanks for helping.
“But I can't get the last reading to be restricted to I, M or D. The reading can also be decoded as a B, P, K or k”
Sounds like you need a relationship that does not match to records where reading is B, P, K or k. Either that or set up a query using ExrcuteSQL such that a where clause can exclude those values.
It seems you might be using the Tires table to store two different types of records; pressure measurement records and depth measurement records. You want the Last() function to be able to pick only from a particular type of record. If I'm right, there are a number of ways to do it. Here's one way.
In the Tires table create a calculation field that returns the foreign key used in the portal only when the Unit field is I, M, or D.
Unit = "I" or
Unit = "M" or
Unit = "D"
VAPfk ; "" )
and another like
Unit = "B" or
Unit = "P" or
Unit = "K or
Unit = "k"
name them something like
VAPfk_depth and VAPfk_pressure
If you build a relationship from the same parent key as the portal to these 'filtered' keys, the Last() function might give the results you want.
I now have the relationship working. But the last () doesn't give the most recent date all the time.
I tried using the Max (), but I not sure how to use the Max (date) for four different fields.
I have the Tread Depth (TD) reading, TD- Date, TD- Miles and TD- Tech.
I want to show the most recent reading for each field based on the Max (Date).
Have you tried sorting the relationship by date?
The last function only works chronologically on an unsorted relationship if the entries are made in order.
If the data looks better in a portal sorted date descending, you could do that and just reference the field.
The correct data would always be in the first record of a descending sorted relationship.
Yes, I tried sorted and unsorted.
I can't rely on readings being put in in order, so I need to use the latest date.
I thought of using a sorted list and then using a lookup.
No sure if that would so it down?
I had a thought,
Last ( List ( VAPfk_depth::Field ) )
List strips out null values, which might get you there...
Last works on related records, not a list of values, but:
Let ( TheList = list ( VAPfk_depth::Field ) ;
GetValue ( TheList ; Length ( theList ) )
would work to get the last value of the list.
but Last also ignores empty values so
Last ( VAPfk_depth::Field )
should also return the last non Empty value of a set of related records.
Retrieving data ...