0
votes

How can I turn the next query:

SELECT Column1, Column2 FROM Table WHERE Column3 < 15

Into Power Query M, I can only perform the first part:

= Table.SelectColumns(#"Table", {"Column1", "Column2"})
2

2 Answers

1
votes

If you prefer single step:

= Table.SelectRows(Table, each [Column3] < 15)[[Column1],[Column2]]
0
votes

Although I use the so-called "Advanced Editor" every day, I'd recommend using the step editor for this query. PowerQuery will then understand how to fold the query (translate the initial steps into SQL) because it generated the M. You can see the SQL from the context menu on a step "View Native Query". This will continue for many of the steps you might add later, such as column renames and calculated columns.

If you start with SQL or get to the point of non-foldable step, including from writing the M code yourself, none or only some of the M is translatable into SQL.

Alternatively (perhaps you know this already), you can put whatever SQL you want straight into the first step using the step editor.