0

Field from newest (sub)record

Dear experts

Can anyone help me? I am trying to budget and plan my revenue and have a table "Customers" and a sub-table "Years" in the sub-table Years I have a field "Total revenue" of this customer in addition to other data

Now I would like to display a field with the most recent "Total revenue" in the Customers table for each customer. I can solve this with last(years.total revenue) but it would be nicer and more correct not to simply take not the last record (although I probably enter the data chronologically in the correct order) but the total recenue from the year with the highest number of this customer.  I can select the data record with max(years.year), but how do I select the „Total revenue“ field from this data record?

Sounds trivial, but I just can't do it. Many thanks for your help

Pascal

3 replies

null
    • Fred
    • 2 wk ago
    • Reported - view

    You can do it in two steps:

    let maxYear := max(year.year);
    year[year = maxYear].'Total revenue'
    
      • John_Halls
      • 13 days ago
      • Reported - view

      Neat!

    • EYEPARC AG
    • Pascal_Imesch
    • 2 wk ago
    • Reported - view

    Thank you very much. I tried it in a similar way bit did not use the correct syntax. I a very grateful for your help.