Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

New Table Distinct value with latest value

I'm trying to create a new table based on another table, In the new table column 1 should be a distinct value(Item nr),column 3 contains lastest price filtered on the date and item nr. I've tried several solutions found on this forum but not geting the result I need.

 

Base Table:

ItemDatePrice
100.15/1/2022  10
200.15/1/202215
300.15/1/202230
100.16/1/202215
200.16/1/202220
300.16/1/202210
100.14/1/202230
200.17/1/202220
300.17/1/202215

Result Table:

ItemDatePrice
100.16/1/2022  15
200.17/1/202220
300.17/1/202215
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    jgeddes 's formula works on my side.

    The new table can then create a relationship with the primary table.

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 Replies

  • With your example data you can create a calculated table with

    Result Table =
    SUMMARIZE(
        'Base Table',
        'Base Table'[Item],
        "_latestDate", MAX('Base Table'[Date]),
        "_lastPrice", CALCULATE(VALUES('Base Table'[Price]),FILTER('Base Table',MAX('Base Table'[Date]) = 'Base Table'[Date]))
    )
     
    to get the table
     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I get the error: The MAX function only accepts a column reference as argument

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        jgeddes 's formula works on my side.

        The new table can then create a relationship with the primary table.

         

         

        Best Regards,

        Stephen Tao

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I'm looking to add the data to a table to create a one to many relation with another table so this won't work for me unfortunatly