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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Addition a specific text in multiple columns in a table

Hi,

I am try to do the following: 

 

I have a text in multiple columns in a table. As the table below:

i have this table and  i want to have the sume of HCL & YF135HTD..etc across all Fluid volume below.

 

TAZ_91_0-1603715068870.png

 

so the output will be

volumes: 

HCL: XX 

YF135HTD: XX

.. etc

 

appreciate your help

Regards,

Anas

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

unpivot.gif

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hcq3DcBAEAPBXhh/oH/5UN52cLj+29CeggEIYs00KSljRYMDPe74K3kyzcyCDS1ODHgiyX+yMGvs6HBhxBtJkfsH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Fluid 1" = _t, #"Fluid 1 Volume" = _t, #"Fluid 2" = _t, #"Fluid 2 Volume" = _t, #"Fluid 3" = _t, #"Fluid 3 Volume" = _t, #"Fluid 4" = _t, #"Fluid 4 Volume" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Fluid 1", type text}, {"Fluid 1 Volume", Int64.Type}, {"Fluid 2", type text}, {"Fluid 2 Volume", Int64.Type}, {"Fluid 3", type text}, {"Fluid 3 Volume", Int64.Type}, {"Fluid 4", type text}, {"Fluid 4 Volume", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Fluid 1 Volume", "Fluid 2 Volume", "Fluid 3 Volume", "Fluid 4 Volume"}, "Attribute", "Value"),
    #"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Unpivoted Columns", {"Attribute", "Value"}, "Attribute.1", "Value.1"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Columns1"," Volume","",Replacer.ReplaceText,{"Attribute.1"}),
    #"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [Attribute] = [Attribute.1] then 1 else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Custom] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom", "Attribute.1", "Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Fluid"}, {"Value.1", "Fluid Value"}}),
    #"Sorted Rows" = Table.Sort(#"Renamed Columns",{{"Fluid", Order.Ascending}})
in
    #"Sorted Rows"

 

 

Best regards

Icey

 

If this post helps,then consider Accepting it as the solution to help other members find it faster.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

unpivot.gif

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Hcq3DcBAEAPBXhh/oH/5UN52cLj+29CeggEIYs00KSljRYMDPe74K3kyzcyCDS1ODHgiyX+yMGvs6HBhxBtJkfsH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Fluid 1" = _t, #"Fluid 1 Volume" = _t, #"Fluid 2" = _t, #"Fluid 2 Volume" = _t, #"Fluid 3" = _t, #"Fluid 3 Volume" = _t, #"Fluid 4" = _t, #"Fluid 4 Volume" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Fluid 1", type text}, {"Fluid 1 Volume", Int64.Type}, {"Fluid 2", type text}, {"Fluid 2 Volume", Int64.Type}, {"Fluid 3", type text}, {"Fluid 3 Volume", Int64.Type}, {"Fluid 4", type text}, {"Fluid 4 Volume", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Fluid 1 Volume", "Fluid 2 Volume", "Fluid 3 Volume", "Fluid 4 Volume"}, "Attribute", "Value"),
    #"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Unpivoted Columns", {"Attribute", "Value"}, "Attribute.1", "Value.1"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Columns1"," Volume","",Replacer.ReplaceText,{"Attribute.1"}),
    #"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [Attribute] = [Attribute.1] then 1 else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Conditional Column", each ([Custom] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom", "Attribute.1", "Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Value", "Fluid"}, {"Value.1", "Fluid Value"}}),
    #"Sorted Rows" = Table.Sort(#"Renamed Columns",{{"Fluid", Order.Ascending}})
in
    #"Sorted Rows"

 

 

Best regards

Icey

 

If this post helps,then consider Accepting it as the solution to help other members find it faster.

DataInsights
Super User
Super User

@Anonymous,

 

The link below explains how to unpivot column pairs (see Approach 2).

 

https://datachant.com/2019/10/11/guest-story-unpivot-pairs-of-columns/

 

Once you unpivot the column pairs, you can create a measure that will sum Fluid Volume.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors