none
Power Query - Add Column with Min Value from another RRS feed

  • Question

  • Hi All,

    I have a set of data that is a Duration (hh:mm:ss.000), but it starts at some non-zero value. I want to subtract the lowest time value in order to get an elapsed time. To do this I figured I would create a new column that has the Minimum Duration value - then create another column that subtracts the Minimum Duration value from the Duration.

    Problem is that I can't figure out how to create a Column with the Minimum value. In excel i would just use a MIN function, but Power Query doesn't recognize the MIN (or Min) function.

    So question is, How do I get a minimum value from a column - OR is there a better way of doing this?

    Thanks

    Tuesday, February 20, 2018 7:21 AM

Answers

  • You can add a new column with this function:

    =List.Min(PreviousStepName[DurationColumn])

    but this is very bad solution.

    Much more effective if you perform it like this:

    let
        Source = YourTable,
        MinDuration = List.Min(Source[DurationColumn]),
        AddColumn = Table.AddColumn(Source, "SomeNewName", each [Duration] - MinDuration)
    in
        AddColumn

    You can easily get this code in your query if you initially just add a new column with "[Duration]-0" formula or something like that, then enter advanced editor and manually add the "MinDuration" step right before the AddColumn step and replace 0 with the name of MinDuration


    Maxim Zelensky Excel Inside

    Tuesday, February 20, 2018 7:33 AM