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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Mic1979
Post Partisan
Post Partisan

Mutiply two columns using Lists and header name

Dear all

 

I have this table. Of course this is an abstract of my dataset:

Mic1979_0-1748785467038.png

 

I need to multiply the columns having "Volumes" and "Distribution" in the header, and I would like to use the lists, as my dataset is much bigger than what I am showing here.

So I created this function:

 

Change_Volume_Header = Table.TransformColumnNames (RemoveServerHelper, each if Text.Contains (_,"Volumes") then _& " OLD" else _),
SelectVolumeColumn = List.Select (Table.ColumnNames (Change_Volume_Header), each Text.Contains (_, "Volumes")),
SelectDistributionColumn = List.Select (Table.ColumnNames (Change_Volume_Header), each Text.Contains (_, "Distribution"))

 

I changed the header adding the "OLD" text because at the end the columns having "OLD" in the header will be cancelled. 

 

Sorry but now I don't know how to proceed. 

I tried this:

Volumes_Year3New = Table.AddColumn (
Change_Volume_Header,
"Volumes_Year3New",
each Record.Field (_,SelectVolumeColumn) * Record.Field (_,SelectDistributionColumn)
)

 

But I got this:

An error occurred in the ‘’ query. Expression.Error: We cannot convert a value of type List to type Text.

 

Any support?

 

Thanks.

 

 

1 ACCEPTED SOLUTION
SundarRaj
Super User
Super User

Hi @Mic1979 ,
This error is because you are multiplying Records with Records when you say Record.Field (_,SelectVolumeColumn) * Record.Field (_,SelectDistributionColumn).

You need to convert Record into a value in order to multiply them together. See the images below. I'll leave the code below. Thanks

SundarRaj_0-1748796832199.png

Solution:

SundarRaj_1-1748796859006.png

Code:

let
Source =
#table(
{"Region (DB Key)", "Project_Step (DB Key)", "Function_Description (DB Key)", "Volumes Year3", "Product_Series_Description (EXPAND)", "Distribution (EXPAND)"},
{
{"AM.", "Step 2.2", "ON/OFF", 715.4, "2 way", 1},
{"AM.", "Step 2.2", "Prop.", 306.6, "2 way", 1},
{"APAC", "Step 2.2", "ON/OFF", 444.5, "2 way", 1},
{"EMEA", "Step 2.2", "ON/OFF", 136.6666667, "2 way", 1},
{"APAC", "Step 2.2", "Prop.", 190.5, "2 way", 1},
{"EMEA", "Step 2.2", "Prop.", 273.3333333, "2 way", 1}
}
),
Change_Volume_Header = Table.TransformColumnNames (Source, each if Text.Contains (_,"Volumes") then _& " OLD" else _),
SelectVolumeColumn = List.Select (Table.ColumnNames (Change_Volume_Header), each Text.Contains (_, "Volumes")),
SelectDistributionColumn = List.Select (Table.ColumnNames (Change_Volume_Header), each Text.Contains (_, "Distribution")),
Custom1 = SelectDistributionColumn,
Custom2 = Table.AddColumn ( Change_Volume_Header , "Volumes_Year3New" , each Record.ToList ( Record.SelectFields ( _ , SelectVolumeColumn ) ){0} * Record.ToList ( Record.SelectFields ( _ , SelectDistributionColumn ) ){0} )
in
Custom2

 

Sundar Rajagopalan

View solution in original post

2 REPLIES 2
SundarRaj
Super User
Super User

Hi @Mic1979 ,
This error is because you are multiplying Records with Records when you say Record.Field (_,SelectVolumeColumn) * Record.Field (_,SelectDistributionColumn).

You need to convert Record into a value in order to multiply them together. See the images below. I'll leave the code below. Thanks

SundarRaj_0-1748796832199.png

Solution:

SundarRaj_1-1748796859006.png

Code:

let
Source =
#table(
{"Region (DB Key)", "Project_Step (DB Key)", "Function_Description (DB Key)", "Volumes Year3", "Product_Series_Description (EXPAND)", "Distribution (EXPAND)"},
{
{"AM.", "Step 2.2", "ON/OFF", 715.4, "2 way", 1},
{"AM.", "Step 2.2", "Prop.", 306.6, "2 way", 1},
{"APAC", "Step 2.2", "ON/OFF", 444.5, "2 way", 1},
{"EMEA", "Step 2.2", "ON/OFF", 136.6666667, "2 way", 1},
{"APAC", "Step 2.2", "Prop.", 190.5, "2 way", 1},
{"EMEA", "Step 2.2", "Prop.", 273.3333333, "2 way", 1}
}
),
Change_Volume_Header = Table.TransformColumnNames (Source, each if Text.Contains (_,"Volumes") then _& " OLD" else _),
SelectVolumeColumn = List.Select (Table.ColumnNames (Change_Volume_Header), each Text.Contains (_, "Volumes")),
SelectDistributionColumn = List.Select (Table.ColumnNames (Change_Volume_Header), each Text.Contains (_, "Distribution")),
Custom1 = SelectDistributionColumn,
Custom2 = Table.AddColumn ( Change_Volume_Header , "Volumes_Year3New" , each Record.ToList ( Record.SelectFields ( _ , SelectVolumeColumn ) ){0} * Record.ToList ( Record.SelectFields ( _ , SelectDistributionColumn ) ){0} )
in
Custom2

 

Sundar Rajagopalan

Working..thanks

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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 Kudoed Authors