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
JRC_JDM
Regular Visitor

Help with Sum column filter

I need to sum costs for all OPID's less than or equal to the current OP ID matching current job.  When in production this power BI table will contain about 100000 jobs with 15-20 operations each and other filters will be applied to make it digestable.

 

I've tried utilizing the Calculate, Sum, Filter, and Earlier options without success.

 

Example of my data from my JobOperations table, the "Total Costs to OP" column is what i'm trying to calcualte without success.

 

Spoiler
JOB IDOP IDMat CostsOH CostsPO CostsTotal Costs to OP
38618010$8000  $8000
38618020 $600 $8600
38618030 $200 $8800
38618040  $100$8900
39152010$5000  $5000
39152020 $300$100$5400

Thank you so much for any help.

 

1 ACCEPTED SOLUTION
lc_finance
Solution Sage
Solution Sage

Hi @JRC_JDM ,

 

 

You can download my proposed solution from here.

 

I created two calculated columns, one with the sum of material, overhead and PO costs. And the second one is Total Costs to OP, which is the column you ask about.

 

Here are the formulas:

Material OH PO costs = 
[Mat Costs]+[OH Costs]+[PO Costs]
Total Costs to OP = 
var currentJobID = [JOB ID]
var currentOpId = [OP ID]
RETURN SUMX(FILTER('Costs OPID', 'Costs OPID'[JOB ID]=currentJobID && 'Costs OPID'[OP ID] <= currentOpId), [Material OH PO costs])

 

And here is a screenshot of the final result:

Total Costs OP.png

 

Is this what you are looking for?

 

LC

Interested in Power BI and DAX tutorials? Check out my blog at www.finance-bi.com

 

View solution in original post

1 REPLY 1
lc_finance
Solution Sage
Solution Sage

Hi @JRC_JDM ,

 

 

You can download my proposed solution from here.

 

I created two calculated columns, one with the sum of material, overhead and PO costs. And the second one is Total Costs to OP, which is the column you ask about.

 

Here are the formulas:

Material OH PO costs = 
[Mat Costs]+[OH Costs]+[PO Costs]
Total Costs to OP = 
var currentJobID = [JOB ID]
var currentOpId = [OP ID]
RETURN SUMX(FILTER('Costs OPID', 'Costs OPID'[JOB ID]=currentJobID && 'Costs OPID'[OP ID] <= currentOpId), [Material OH PO costs])

 

And here is a screenshot of the final result:

Total Costs OP.png

 

Is this what you are looking for?

 

LC

Interested in Power BI and DAX tutorials? Check out my blog at www.finance-bi.com

 

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.