Forum Discussion

RalphHoffmann's avatar
RalphHoffmann
Regular Visitor
3 years ago
Solved

Work with dates

Hello, I am importing charging data from a charging station for electric cars. To be able to calculate the cost of the charged energy, the date when the charging was started is important. The cost ...
  • RalphHoffmann's avatar
    RalphHoffmann
    3 years ago

    Hi Alexandre,

    now your code work 😉

    I have written a query with the code (see below). I call this query in a custom column. It always finds the correct price!

    Thanks for your help!!!

     

     

    (FieldInput as datetime) =>
    let
        qSource = Excel.CurrentWorkbook(){[Name="tbl_CostPerTime"]}[Content],
        qRow = Table.SelectRows(qSource, each ([ValidFromDate]<=FieldInput)),
        qContent=
                Table.Sort(qRow,{{"ValidFromDate", Order.Ascending}})[Value]{Table.RowCount(Table.Sort(qRow,{{"ValidFromDate", Order.Descending}})) - 1} 
    in
    qContent