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
Anonymous
Not applicable

Subtraction multiplication and sum of variables in table

Hi,

 

I have a table for average prices and weights sorted by the Start of Week Date (SoW)

I'm hoping to acheive something like this in the form of a new column 

(Average Price Paid GB SQQ Price * Total Intake Data Cold Weight = Additional Cost Total)

 

I'm hoping to find the overall sum of this Additional Cost Total column i.e. 

 

Can anyone help?

1 ACCEPTED SOLUTION

@Anonymous - I did this:

 

 

Measure 2 = (AVERAGE('Sheet1 (2)'[Intake_Data_Price]) - [Average SQQ Price YTD]) * SUM('Sheet1 (2)'[Intake_Data_Cold_Weight])

 

 

See attached, not coming up with exactly your numbers.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

13 REPLIES 13
amitchandak
Super User
Super User

Create a new column like this

Additional Cost Total = ([Average Price Paid] - [GB SQQ Price]) * [Total Intake Data Cold Weight]

 

Then sum it up.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Greg_Deckler
Super User
Super User

Should be able to create a column in the table:

Additional Cost Total = [Average Price Paid] - [GB SQQ Price] * [Total Intake Data Cold Weight]

And then just use a default SUM aggregation to the get total for the entire column.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

So I have written a formula:

Additional Cost Total = ('Sheet1 (2)'[AverageIntakeDataPrice]) - ('GB SQQ Price Data'[Average SQQ Price YTD]) * ('Sheet1 (2)'[Intake_Data_Cold_Weight])
 
NOTE: I'm using variables from two separate tables (1) Sheet1 (2) & (2)GB SQQ Price Data. I have created a relationship based on SoW between the two tables. But I keep getting this error:
 
"This expression refers to a Column object named 'GB SQQ Price Data[Column]', which has an error."
 
Would the layout of the data be an issue?
 

 

Anonymous
Not applicable

 

 

You need to do it on a common dimension. That dimension can be date and product etc

like


Additional Cost Total =

sumx(summarize(Table,Table[SoW],"_1" ,max('Sheet1 (2)'[AverageIntakeDataPrice]) , "_2",max('GB SQQ Price Data'[Average SQQ Price YTD]) ,"_3", sum('Sheet1 (2)'[Intake_Data_Cold_Weight])),([_1]*[_2])*[_3])

 

This table is a common dimension.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

I've written this into a new column in the GB SQQ Price Data table:
 
Additional Cost Total edit =

sumx(summarize('Start of Week Sort','Start of Week Sort'[SoW],"_1" ,max('Sheet1 (2)'[AverageIntakeDataPrice]) , "_2",max('GB SQQ Price Data'[Average SQQ Price YTD]) ,"_3", sum('Sheet1 (2)'[Intake_Data_Cold_Weight])),([_1]*[_2])*[_3])
 
and this error pops up?
 
"Column 'AverageIntakeDataPrice' in table 'Sheet1 (2)' cannot be found or may not be used in this expression."

@Anonymous Any way you can share your PBIX? This can likely get taken care of fairly easily but it is very difficult without being able to see your table structures, data and how they can be related to one another.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@amitchandak 

@Greg_Deckler 

Would this work?

@Anonymous - I did this:

 

 

Measure 2 = (AVERAGE('Sheet1 (2)'[Intake_Data_Price]) - [Average SQQ Price YTD]) * SUM('Sheet1 (2)'[Intake_Data_Cold_Weight])

 

 

See attached, not coming up with exactly your numbers.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 

I'm having a similar issue again with the summation of total "COP Cost YTD" i.e. in this formula (X-Y *Q)

 

As you suggested I have built a measure:

 

Measure 3 = (([Filtered Average Intake Price]) - [Min Industry Start Value £]) * ([Filtered Total Intake Data Cold Weight])
 
and then 
COP Cost YTD. = IF(HASONEVALUE('Start of Week Sort'[SoW]),[Measure 3],
SUMX(
SUMMARIZE(
'Start of Week Sort',
"__Measure",[Measure 3]
),
[__Measure]
))
Any ideas?

@Anonymous , I agree with @Greg_Deckler , Share a pbix.

I doubt the Start of Week Sort is not joined to Sheet1 (2) the table for which it gives error

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@Anonymous What table are you creating this new column in? You will likely need to use RELATED or RELATED table, like:

 

Additional Cost Total = ('Sheet1 (2)'[AverageIntakeDataPrice]) - RELATED('GB SQQ Price Data'[Average SQQ Price YTD]) * ('Sheet1 (2)'[Intake_Data_Cold_Weight])



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler I was hoping to create it in the GB SQQ Price Data table as I need the data in the Monday Start of each week format:

 

So when I enter this formula, the following is underlined

Additional Cost Total = ('Sheet1 (2)'[AverageIntakeDataPrice]) - RELATED('GB SQQ Price Data'[Average SQQ Price YTD]) * ('Sheet1 (2)'[Intake_Data_Cold_Weight])

 

But I get the error that I need to create a relationship: The column 'GB SQQ Price Data[Average SQQ Price YTD]' either doesn't exist or doesn't have a relationship to any table available in the current context.

 

However as Average SQQ Price YTD is different I'm not sure what to relate it to?

 

Should I just create a brand new table pulling in each of these variables that I need?

 

 

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!

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.

Top Solution Authors