Notifications
Clear all
Power Query
4
Posts
2
Users
0
Reactions
99
Views
Topic starter
Hi Guys,
i want to add statement to PQ to clear table if namedRange in Excel = True.
It should be a function which i can implement for every power query table in workbook.
Please help,
Jacek
Posted : 05/03/2021 11:23 am
Hi Jacek,
After loading the table you can check the value of the NamedRange then use Table.RemoveRows to clear the table but leave the columns intact
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Col1", Int64.Type}, {"Col2", Int64.Type}, {"Col3", Int64.Type}}),
Conditional_Remove = if NamedRange{0}[Column1] = "Yes" then Table.RemoveRows(#"Changed Type",0,Table.RowCount(#"Changed Type")) else #"Changed Type"
in
Conditional_Remove
Regards
Phil
Posted : 06/03/2021 12:51 am
Topic starter
Thank you so much!
Jacek
Posted : 06/03/2021 1:58 am
No worries.
Posted : 09/03/2021 10:44 pm