Forum

Clear table if Name...
 
Notifications
Clear all

Clear table if NamedRange = true

4 Posts
2 Users
0 Reactions
99 Views
(@jaryszek)
Posts: 177
Reputable Member
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

 

Screenshot_134.png

 
Posted : 05/03/2021 11:23 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

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
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Thank you so much!

 

Jacek

 
Posted : 06/03/2021 1:58 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

No worries.

 
Posted : 09/03/2021 10:44 pm
Share: