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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
kelly008
Helper I
Helper I

Multiplication Between Columns in the same table

Hello,

 

I am currently trying to multiply two columns in the same table, but when I do I get the wrong total's at the bottom or the wrong line data depending on the formula's I've tried to use. 

 

From this table, all I want to do is multiply the 'Expected_Quantity' Column by the 'Unit_Cost' column.

kelly008_0-1653039787524.png

 

I have tried two different tests to get this to work, the first being to create a measure with the following formula:

TEST1 = SUM('RelProdOrderComponents'[Expected_Quantity]) * SUM('RelProdOrderComponents'[Unit_Cost])
 
This provides the correct line data, but the total is wrong.
 
kelly008_2-1653040186152.png

 

As you can see the line data is right, but the total is way out. 

 -----------------------------------------------------------------------------------------------------------
The second test was using a custom column with the following formula:
 
Test2 CustomColumn = [Expected_Quantity]*[Unit_Cost]
 
This however, gives some of the correct line data and does give a more realistic total at the bottom:

kelly008_1-1653040129432.png

But, as you can see not all of thes row are correct.

 

Can I please have some help with how I get the table to have the correct line and total data. 

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@kelly008 I think you mean you want to do something like that:

 

MEASURE = 
SUMX(
     'RelProdOrderComponents',
     'RelProdOrderComponents'[Expected_Quantity] *
     'RelProdOrderComponents'[Unit_Cost])
)
 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

12 REPLIES 12
kelly008
Helper I
Helper I

Hi, Yes i did haha thanks for noticing 🙂 

 

So, essentially this table is a summary of materials used against a construction project. The goal is to show exactly how much was spent on materials per material type in rows (Description column) as well as on a whole via the total of unit cost * expected quantity columns.

kelly008_0-1653043025697.png

'Expected quantity' & 'Unit cost' are columns within the 'RelProdOrderComponents' Table.

 

The data table is this:

kelly008_1-1653043312410.png

 



by your latest picture you want the total to be equal to:
10270 * 5713009 = 586672602430 ?
Cause that what you get in the original post and said it's not what you want.
You will get this with indeed what you wrote in the beginning:
TEST1 = SUM('RelProdOrderComponents'[Expected_Quantity]) * SUM('RelProdOrderComponents'[Unit_Cost])

What am I missing here? I guess I still just don't understand what you want to get haha

Hi,

 

Sorry for the confusion, I was simply drawing out how the formula is going as per your request.

 

The total itself however is very very wrong. 

 

What I want is for the Test 1 Formula to actually provide the correct total, the rows are correct just not the total at the bottom. If you do the calculation outside of PowerBI it should roughly be 6 million not 586 million. 

@kelly008 ok, try this:

 

 

MEASURE = 
SUMX(
     VALUES('RelProdOrderComponents'[Description]),
     CALCULATE(SUM('RelProdOrderComponents'[Expected_Quantity]) *
     CALCULATE(SUM('RelProdOrderComponents'[Unit_Cost]))
)

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Hi,

 

So this goes to the other method that I tried in 'Test2 CustomColumn' where it appears to get the total right but not the row data:

kelly008_1-1653045119033.png

 

As you can see, the line with the red X is not calculating correctly, it should be doing 18 * £334.24 which is £6016.29 (If you look at the column TEST 1, you can see the correct row values) and not £1894.24.  



Hi, just to add on here, although there is a red tick next to the total, it still isnt right even though the number is more realistic than 600 million. Sorry if that confuses anything.

ok wait 🙂 in your visual, excpected qunatity and unit cost are implicit measures right? You just added the columns there, right? What is the summarization of these columns? SUM / AVERAGE / Something else?

So.... Both are just columns from the RelProdOrderComponent.

 

Summarisation wise:

 

kelly008_0-1653047345939.png

 

kelly008_1-1653047365173.png

 

Great! It's just SUM, so I have no clue 🤣, I will PM you

SpartaBI
Community Champion
Community Champion

@kelly008 I think you mean you want to do something like that:

 

MEASURE = 
SUMX(
     'RelProdOrderComponents',
     'RelProdOrderComponents'[Expected_Quantity] *
     'RelProdOrderComponents'[Unit_Cost])
)
 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Hi,

 

Thanks for replying, when I use the code you have provided I get this:

kelly008_0-1653040933381.png

 

Oddly, If I take the last bracket out I get this:

kelly008_1-1653040965373.png

Which basically just adds in another column that has the same value as column 'Test2 CustomColumn'.

 



@kelly008 you had a bracket down down below 🙂
Anyway, so I didn't understand what you want to achieve.
Can you share the visual you have without testing and just the column of the desired result by drawing the logic and the expected number.
Also, Expected_Quantity] and [Unit_Cost] are they measures or columns? If measures what are they?
Is [description] a key in your table or a value that represnet multile rows?
Can you share also a screenshot of the data model table

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.