cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kevindmonte
Helper II
Helper II

Help with Custom Function

Hi, 
Power query learner here. I am trying to create a custom function. I have a table which after initial processing still contains column headers that start with the text "Column". I wanted to invoke this function on the last step so then I can get rid of all these columns that start with "Column". 

I used below function but what it is doing is returning a table with all columns that start with "Column" text rather than removing it. Any idea how to fix this? 

 

 

(InputQueryTable as table) =>
let
Source = #"InputQueryTable",
#"Column Names" = Table.ColumnNames(Source),
#"Columns Containing String" = List.FindText(#"Column Names", "Column"),
//#"Columns Containing String" = List.Contains( #"Column Names", "", Text.StartsWith( "Column") ),
//#"Columns Containing String" = List.FindText(#"Column Names", Text.StartsWith( "Column") ),
#"List Difference" = List.Difference( #"Column Names", #"Columns Containing String"),
#"Removed Columns" = Table.RemoveColumns(Source, #"List Difference")
in
#"Removed Columns"

 

 

1 ACCEPTED SOLUTION
kevindmonte
Helper II
Helper II

Hi, 
found the answer myself. Updated code below. 

sum(Earned Hours )  / Sum(CurrentEst)

(InputQueryTable as table) =>
let
Source = #"InputQueryTable",
#"Column Names" = Table.ColumnNames(Source),

#"Columns Containing String" = List.FindText(#"Column Names", "Column"),

#"Removed Columns" = Table.RemoveColumns(Source, #"Columns Containing String")
in
#"Removed Columns"

 

View solution in original post

1 REPLY 1
kevindmonte
Helper II
Helper II

Hi, 
found the answer myself. Updated code below. 

sum(Earned Hours )  / Sum(CurrentEst)

(InputQueryTable as table) =>
let
Source = #"InputQueryTable",
#"Column Names" = Table.ColumnNames(Source),

#"Columns Containing String" = List.FindText(#"Column Names", "Column"),

#"Removed Columns" = Table.RemoveColumns(Source, #"Columns Containing String")
in
#"Removed Columns"

 

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors