Forum

Bulk processing col...
 
Notifications
Clear all

Bulk processing columns

4 Posts
2 Users
0 Reactions
37 Views
(@lanser)
Posts: 63
Estimable Member
Topic starter
 

Hi,

I have a query pulling data from a folder of 20-30 workbooks, in those workbooks are between 10-15 columns that I need to clean up, these columns all start with "AM/M" I have a representation of the code below (with a few more nested ifs), how can I run this without having to manually add a custom column for eac AM/M and handle varying numbers of columns.

thanks

John

if [#"AM/Mxxx)"]=null then 
null 
else if Text.StartsWith([#"AM/Mxxx"], "<") then 
    	Number.From(Text.Middle([#"AM/Mxxx"], 1)) / 2 
    		else if Text.StartsWith([#"AM/Mxxx"], "Not") then 
 	0
   			 else if Text.StartsWith([#"AM/Mxxx"], "Detected") then 
    			1
else 
    Number.From([#"AM/Mxxx"])

 

 
Posted : 01/08/2025 12:14 am
Riny van Eekelen
(@riny)
Posts: 1274
Member Moderator
 

@lanser

Difficult to visualise exactly what you are dealing with, but my gut feeling says that you could unpivot the data first and then use the “Attribute” column (probably) to test if the text in it starts with “AM/M” and if so then do the Number.From part. And then pivot all back.

Not sure though. Can you upload an example of a file with the real column names and some fake data?

 
Posted : 01/08/2025 1:11 am
(@lanser)
Posts: 63
Estimable Member
Topic starter
 

Added file with identifying details removed, and I lied I just noticed Columns AB:AM will also need cleaning but they dont start with AM/M

 

 
Posted : 01/08/2025 1:28 am
Riny van Eekelen
(@riny)
Posts: 1274
Member Moderator
 

Aha! Then please explain all the logic to be applied.

Edit: Perhaps the attached file does what you need.

 

 

This post was modified 8 hours ago 3 times by Riny van Eekelen
 
Posted : 01/08/2025 2:23 pm
Share: