Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Custom Function Add column for each binary

I'm working on an agg table, and I need to add a column (from the binary) to the initial table.

I want to do it without doing all of the combining and expanding and all other transforms - just need the one column - which happens to be an extraction of characters from one field in the file.

 

Here is my initial table...

KimberlyF_0-1656021026421.png

and here is the drilldown of the binary to get to what I want...

 

Content = #"Removed Other Columns"{0}[Content],
#"Imported Text" = Table.FromColumns({Lines.FromBinary(Content,null,null,1252)}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Imported Text", {{"Column1", each Text.BeforeDelimiter(_, "|"), type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Extracted Text Before Delimiter",{{"Column1", "RecordType"}})

 

I beleive I can do a function to add this column for each of the binary.
Can anyone please provide the function to add column to my original table?

I'll then delete the binary column and do some aggregating.

 

Thank you!
 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Your idea is doable. You can create a blank query and paste below code into it. This query will become a custom function which has a parameter paraContent requiring a binary value. 

(paraContent as binary)=>
let
#"Imported Text" = Table.FromColumns({Lines.FromBinary(paraContent,null,null,1252)}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Imported Text", {{"Column1", each Text.BeforeDelimiter(_, "|"), type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Extracted Text Before Delimiter",{{"Column1", "RecordType"}})
in
#"Renamed Columns"

 

Then in the initial query, click "Invoke Custom Function" beneath Add Column tab. In Invoke Custom Function window, select above function and select Content column for the paraContent parameter. 

vjingzhang_0-1656401578697.png

 

In the new column, you will have a table value in each cell. This table value is the result of the custom function. 

vjingzhang_1-1656402062518.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Your idea is doable. You can create a blank query and paste below code into it. This query will become a custom function which has a parameter paraContent requiring a binary value. 

(paraContent as binary)=>
let
#"Imported Text" = Table.FromColumns({Lines.FromBinary(paraContent,null,null,1252)}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Imported Text", {{"Column1", each Text.BeforeDelimiter(_, "|"), type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Extracted Text Before Delimiter",{{"Column1", "RecordType"}})
in
#"Renamed Columns"

 

Then in the initial query, click "Invoke Custom Function" beneath Add Column tab. In Invoke Custom Function window, select above function and select Content column for the paraContent parameter. 

vjingzhang_0-1656401578697.png

 

In the new column, you will have a table value in each cell. This table value is the result of the custom function. 

vjingzhang_1-1656402062518.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors