Forum Discussion
skip query step if condition is met
- 1 year ago
Thanks for the help. I found the solution I was looking for. The script should look like the following:
let
Source =
if List.Single(DateList) = null then
Excel.Workbook(File.Contents(""C:\Mydocuments\Test.csv"), null, true)
else
null, // Preventing further steps if Source is null
Output =
if Source = null then
#table({}, {}) // Returns an empty table
else
let
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", Int64.Type}, {"Code", Int64.Type}, {"Value", Int64.Type}})in
#"Changed Type"in
Output
Hi Phil_Oliveira, it is possible.
add another new step at the end of your Combined_Exp_ query. Something like this:
= if List.IsEmpty(YourList) then #table(null, {}) else #"Changed Type"
or (but this one does not make sense to me because list can not be null...)
= if YourList is null then #table(null, {}) else #"Changed Type"
- Phil_Oliveira1 year agoNew Member
Thanks for the help. I am new with power query so I am not sure if I got it right. Should the query look something like this:
let
Source = Csv.Document(File.Contents("C:\Mydocuments\Test.csv"),[Delimiter=",", Columns=83, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", Int64.Type}, {"Code", Int64.Type}, {"Value", Int64.Type}}),#"Test" = if not List.IsEmpty(DateList) then #table(null, {}) else #"Changed Type"
in
#"Changed Type"- dufoq31 year agoCommunity Champion
let
Source = Csv.Document(File.Contents("C:\Mydocuments\Test.csv"),[Delimiter=",", Columns=83, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", Int64.Type}, {"Code", Int64.Type}, {"Value", Int64.Type}}),#"Test" = if not List.IsEmpty(DateList) then #table(null, {}) else #"Changed Type"
in
#"Test"