Friday, 7 July 2023

Hello

let

    // Find the maximum car model from the Car Model table

    MaxCarModel = List.Max(CarTable[CardModel]),


    // Define the function to find the car model for each date

    FindCarModel = (date) =>

        let

            CarModelRow = Table.SelectRows(CarTable, each [Startdate] <= date and date <= [EndDate] and [CardModel] = MaxCarModel),

            CarModel = if Table.IsEmpty(CarModelRow) then MaxCarModel else Record.Field(CarModelRow{0}, "CardModel")

        in

            CarModel,


    // Add a custom column with the car model for each date

    CarModelColumn = Table.AddColumn(Calendar, "CarModel", each FindCarModel([Date]))

in

   

 CarModelColumn