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
DauletKali
Helper I
Helper I

Calculating unit cost of production

Hi there! I need your help in solving a problem 

I need to show unit cost by a particular month and by accumulating several month. It is ok when I choose only one month, but when I want to accumulate data for several months it just summarize unit cost. For example, if unit cost for first month is 2 unit and for the second month is 3 unit, when I combine those month together (1+2) instead of showing 2,5 it shows the sum of theese two figures - 5.  What dax function should I use to make it right? Thanks 

 

Here is my pbix example file 

 

Thanks in advance 

 

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @DauletKali ,

 

You can use the following measure to calculate accumulating unit cost:

 

 

AccumulatingUnCost = CALCULATE(SUM(Actual[ActualUnCost]),FILTER(ALL(Data),MONTH(Data[Date])<=MONTH(MAX(Data[Date])) && YEAR(Data[Date]) = YEAR(MAX(Data[Date])))) 

 

 

Capture.PNG

 

 
 

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

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @DauletKali ,

 

You can use the following measure to calculate accumulating unit cost:

 

 

AccumulatingUnCost = CALCULATE(SUM(Actual[ActualUnCost]),FILTER(ALL(Data),MONTH(Data[Date])<=MONTH(MAX(Data[Date])) && YEAR(Data[Date]) = YEAR(MAX(Data[Date])))) 

 

 

Capture.PNG

 

 
 

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

 

Best Regards,

Dedmon Dai

amitchandak
Super User
Super User

@DauletKali , You can get rolling like this but with a date table

 

Rolling 12 = CALCULATE(Divide(sum(Table[Revenue]),Sum(Table[Unit])),DATESINPERIOD('Date'[Date],ENDOFMONTH(Table[Date]),-12,MONTH))
Rolling 12 = CALCULATE(Divide(sum(Table[Revenue]),Sum(Table[Unit])),DATESINPERIOD('Date'[Date ],MAX(Table[Date]),-12,MONTH))
Rolling 12 = CALCULATE(Divide(sum(Table[Revenue]),Sum(Table[Unit])),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Sumanth_23
Memorable Member
Memorable Member

hi @DauletKali - Apologies I am unable to understand the field names in your sample file. 

 

But if you are using the unit price column directly in a visual - you should be able to select that the field should not be summarized as seen in the below screen grab. 

 

Unit Cost - sum.jpg

 

Unit Cost - sum2.jpg

 

Please mark the post as a solution if my comment helped with solving your issue. Thanks! 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors