Search code examples
powerbim

M query - How to refer to the 5th entry in Column B in a table?


In Power Query (M query), I am trying to add a custom column to a table, where every item of that column has the same value, equal to that of the entry in the 5th row of Column B in that same table.

What custom column formula should I use? - I have tried the following but this throws an error:

=[ColumnB]({5})

In essence, I just need to know how to refer to the nth row in Column B. I'm finding this surprisingly difficult to figure out.

Thanks a lot.


Solution

  • You should delete the brackets around the element and add the name of the previous step in your query script. Like this:

    = #"previous step"[ColumnB]{4}
    

    When you want the value from the fifth row, that is element {4}.

    enter image description here