How can I perform COALESCE in power query?

You can try the null coalescing operator (??). Both of the following lines achieve the same effect of returning ValueA unless it is null, in which case ValueB is returned.

if ValueA <> null then ValueA else ValueB
ValueA ?? ValueB

Applied to your specific case the necessary code would be:

[Q4] ?? [Q3] ?? [Q2] ?? [Q1]

Note that the null coalescing operator is a new addition to Power Query. It has not been officially documented yet and may not be available in all environments.

Information taken from this blog post.


There are a couple formulas you can use when adding a custom column to the table (accessible from the Transform ribbon tab). Here's one:

if [Q4] <> null then [Q4] else if [Q3] <> null then [Q3] else if [Q2] <> null then [Q2] else [Q1]

If you don't want to write so many if statements, you can add the columns to a list and filter out the null values:

List.Last(List.Select({[Q1], [Q2], [Q3], [Q4]}, each _ <> null))