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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
rajibmahmud
Helper III
Helper III

Cost calculation from Bottomup

Hi Team,

 

I am trying to calculate a cost using bottom up method at monthly level.

 

Where cost would be Vol sold in Month 1, multiplied by Cost in month 1 at Product Level. The total year cost would be Month 1 vol * month 1 cost + Month 2 vol * month 2 cost .... this way.

 

And the Brand cost would be sum of this from bottom up. However when ever I tried to do it using calculate, the Full year number is Cost of 1 + Cost of 2 ... * total volume, which is incorrect. I am attaching PBI file, can someone guide me on this.

 

Below is the link

 

https://1drv.ms/f/s!AuSkszFGzDQzjSL9CxVCzI8VXYGN

 

 

13 REPLIES 13
Floriankx
Solution Sage
Solution Sage

If you have vol. and cost column in your table use Sumx

 

Total_Cost:=(Table,[vol]*[cost]). This should end up as supposed.

Due to company restrictions I am not able to check out your provided link.

So maybe just some information of your data structure would be fine.

 

Best regards.

@Floriankx

 

The source data's are in 2 different table. I couldnt connect those using Sumx for some reason, although the tables are connected via relation.

 

Data would look like below:

 

YearMonthChannelSKUValueMeasure

20171RuralAAA57Volume
20172RuralAAA51Volume
20173RuralAAA56Volume
20174RuralAAA39Volume
20175RuralAAA51Volume
20176RuralAAA51Volume
20177RuralAAA57Volume
20178RuralAAA53Volume
20179RuralAAA46Volume
201710RuralAAA46Volume
201711RuralAAA56Volume
201712RuralAAA38Volume

 

 

YearMonthSKUSCC.Ton

20171AAA11
20172AAA13
20173AAA14
20174AAA15
20175AAA10
20176AAA14
20177AAA17
20178AAA18
20179AAA11
201710AAA15
201711AAA18
201712AAA10
20171AAB17
20172AAB18
20173AAB16
20174AAB16
20175AAB14
20176AAB17
20177AAB16
20178AAB14
20179AAB17
201710AAB18
201711AAB18
201712AAB16

Can you add headings please.

 

How did you relate the tables?

When I pasted table, the header disappeared for some reason. Pasted again..


Year             Month      SKU         SCC.Ton

20171AAA11
20172AAA13
20173AAA14
20174AAA15
20175AAA10
20176AAA14
20177AAA17
20178AAA18
20179AAA11
201710AAA15
201711AAA18
201712AAA10
20171AAB17
20172AAB18
20173AAB16
20174AAB16
20175AAB14
20176AAB17
20177AAB16
20178AAB14
20179AAB17
201710AAB18
201711AAB18
201712AAB16

 

Year             Month     Channel     SKU          Value       Measure

20171RuralAAA57Volume
20172RuralAAA51Volume
20173RuralAAA56Volume
20174RuralAAA39Volume
20175RuralAAA51Volume
20176RuralAAA51Volume
20177RuralAAA57Volume
20178RuralAAA53Volume
20179RuralAAA46Volume
201710RuralAAA46Volume
201711RuralAAA56Volume
201712RuralAAA38Volume
20171RuralAAB49Volume
20172RuralAAB31Volume
20173RuralAAB41Volume
20174RuralAAB52Volume
20175RuralAAB35Volume
20176RuralAAB37Volume
20177RuralAAB57Volume
20178RuralAAB59Volume
20179RuralAAB58Volume
201710RuralAAB54Volume
201711RuralAAB49Volume
201712RuralAAB45Volume

 

U created distinct table for SKU/Product, Month , Year etc to related the tables.

And what is your expected result?

 

At the moment it seems you have one value per product and month so every value is unique.

In this case, Sum([Value] should be fine.

 

But maybe i misunderstood something.

It would be easier if you could open the excels and PBI files.

 

So what is happening is, when I am looking at the cost at month level the number is ok. System is pulling sales Quantity at monthly level and multiplying the monthly cost from another table which is linked.

 

However when I am looking at the sum or looking at data at quarter level using drilldown option, PBI is not calculating the cost from bottom up, rather its summing the cost and doing the calculation.

 

Below example will clarify.

 

Cost of Jan is 10 * Vol of Jan is 20 = 200 

Cost of Feb is 11 * Vol 30 = 330

Cost of Mar is 10 * Vol 30 = 300

 

Hence the Quarter cost should be = 200+330+300 = 830

 

But when I am using drilldown the result is = (10+11+10) * (20+30+30) =  2480.

 

The cost is getting calculated incorrectly.

Hello so SUMX(Table;[Cost of Month]*[Volume of Month]) should give you your expected result.

Hi, Cost of month is in seperate table. Hence I cant use Sumx.

 

Than again, I could use Sumx in combination with Related. But I cant use it, as the tables are connected via an intermediate table, as both table have repeated Product code/name due to multiple Year, Month.

Hello is the combination of Month, Year and SKU unique in each table?

 

If it would be you could use the following:

Measure:=SUMX(fCost;
VAR Actual_Year=fCost[Year]
VAR Actual_Month=fCost[Month]
VAR Actual_SKU=fCost[SKU] RETURN
fCost[Cost]*CALCULATE(SUM(fValue[Value]);FILTER(fValue;fValue[Year]=Actual_Year&&fValue[Month]=Actual_Month&&fValue[SKU]=Actual_SKU)))

Assumptions made:

Table with Cost is named fCost

Table with Volume is named fValue. Volume is here called Value.

Measure is created in fCost table.

The combination of Year, Month and SKU is unique in each row of fCost.

Now combination (Year, Month, SKU) appears in fValue which is not in fCost.

Tables are not related.

 

If you create a Pivot with Year, Month and SKU from fCost it should be fine.

It doesnt work. As in the tables Month and Year is not unique due to dataset nature.

Could have been tables aggregated to Year, Month and SKU.

 

In this case it probably would be best to create a DateTable (dDate) with distinct Year and Month Values.

Additionally I would create a distinct table for SKU (dSKU).

The tables shouldn't be related.

The I added in dDate the following Measure:

Total Cost:=SUMX(dSKU;
var Actual_SKU=dSKU[SKU]
var Date_Value=SUMX(dDate;
	var Actual_Year=dDate[Year]
	var Actual_Month=dDate[Month Number]
	var Cost_per_month=CALCULATE(SUM(fCost[SCC.Ton]);FILTER(fCost;fCost[Year]=Actual_Year&&fCost[Month]=Actual_Month&&fCost[SKU]=Actual_SKU))
	var Value_per_month=CALCULATE(SUM(fValue[Value]);FILTER(fValue;fValue[Year]=Actual_Year&&fValue[Month]=Actual_Month&&fValue[SKU]=Actual_SKU))
	Return Cost_per_month*Value_per_month)
Return Date_Value)

Please check it out.

 

There would also be the possibilitie of creating dates out of Month and Year and relate them to your date table.

Thanks a lot. I will put it in my model and try.

 

But it seems in Filter I have to put Year hard coded rather than it being dynamic. Am I right?

Hello,

 

no it is not hard coded. With VAR you define your actuals dynamically.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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