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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.


@ 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!:
The Definitive Guide to Power Query (M)

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.

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.

@ 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!:
The Definitive Guide to Power Query (M)

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.

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.


@ 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!:
The Definitive Guide to Power Query (M)

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.


@ 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!:
The Definitive Guide to Power Query (M)

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

@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])


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors