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

Multiply column with several other columns individually

Hi,

 

I have 10 columns that I want to multiply with a column called FX.

 

For example, I have columns:

 

1. Sales

2. Salaries

3. Tax

4. FX rate

 

I want to new columns equal to:

 

1. Sales*FX rate

2. Salaries*FX rate

3. Tax*FX rate

 

 

What would be the most elegant way to do this? I am open to using power query or dax. I know how to do this in other programming languages (i.e. a simple loop) but am new to power BI, any help would be appreciated.

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Thanks, is there a way to do this programmtically:

 

For each col in my columns:

   new_col = col * multiplication column

   add new_col to table

View solution in original post

HotChilli
Super User
Super User

I've had a go.  You'll have to incorporate this into your Power Query code with your previous step names etc.

#"stepNext" = List.Accumulate(Table.ColumnNames(#"Inserted Multiplication"), #"Inserted Multiplication", 
    (state, current) => 
      Table.AddColumn(state, "XX " & current, each [Multiplication] * Record.Field(_, current), Int64.Type) )

There's no foreach in M, it's functional programming so we pass a list of column names to the function List.Accumulate and say what we want to do with those column names.

 

View solution in original post

4 REPLIES 4
HotChilli
Super User
Super User

I've had a go.  You'll have to incorporate this into your Power Query code with your previous step names etc.

#"stepNext" = List.Accumulate(Table.ColumnNames(#"Inserted Multiplication"), #"Inserted Multiplication", 
    (state, current) => 
      Table.AddColumn(state, "XX " & current, each [Multiplication] * Record.Field(_, current), Int64.Type) )

There's no foreach in M, it's functional programming so we pass a list of column names to the function List.Accumulate and say what we want to do with those column names.

 

v-xulin-mstf
Community Support
Community Support

Hi @Anonymous

 

You can create three measures as:

Sales*FX rate=
Calculate
   (
     max('table'[Sales])*max('table'[FX rate]),
     'table'
    )
Salearires*FX rate=
Calculate
   (
     max('table'[Salearires])*max('table'[FX rate]),
     'table'
    )
Tax*FX rate=
Calculate
   (
     max('table'[Tax])*max('table'[FX rate]),
     'table'
    )

 

Best Regards,

Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks, is there a way to do this programmtically:

 

For each col in my columns:

   new_col = col * multiplication column

   add new_col to table

HotChilli
Super User
Super User

You've basically shown how to do it right there.  Just go to Power Query->add a new column ,either custom column and add code manually or

use the interface (select 2 columns -> use the ribbon in the (standard->multiply) - in the 'From number' section.

You'll work it out

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