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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
cheid_4838
Helper IV
Helper IV

How to divide cost by count of duplicate order numbers

I have a dashboard that contains repair orders and the estimated cost for the entire repair.  Some of the repairs have more than one line. The estimated cost shown in the screenshot needs to be split between each line.  I tried dividing the cost up using max section sequence and counting the ordernumber or PO Number.  When I create a measure I have to sum the estimated cost so I get the original value when I divide by the section sequence # or counting the order#/PO#.  Is there anyway to divide the estimated cost by the stop sequence number or PO# count without having to sum the estimated cost?  Thanks in advance for your help.

 

 

cheid_4838_1-1725459303089.png

 

 

1 ACCEPTED SOLUTION

Hi @cheid_4838 ,

How about updating the measure as shown below?

Average Estimate by Max Section Sequence (update) = 
VAR MaxSectionSequence = 
    CALCULATE(
        MAX('Table'[Section Sequence]), 
        ALLEXCEPT('Table', 'Table'[PO Number])
    )
VAR TotalEstimate =
    CALCULATE(
        max('Table'[Estimate]), 
        ALLEXCEPT('Table', 'Table'[PO Number])
    )
RETURN
   sumx('Table', TotalEstimate / MaxSectionSequence)

 

The output is shown below:

DataNinja777_0-1725496344990.png

I have attached a sample pbix file.

 

View solution in original post

6 REPLIES 6
DataNinja777
Super User
Super User

Hi @cheid_4838 ,

What about using max instead of sum to aggregate Estimate value?  

Average Estimate by Max Section Sequence = 
VAR MaxSectionSequence = 
    CALCULATE(
        MAX('Table'[Section Sequence]), 
        ALLEXCEPT('Table', 'Table'[PO Number])
    )
VAR TotalEstimate =
    CALCULATE(
        max('Table'[Estimate]), 
        ALLEXCEPT('Table', 'Table'[PO Number])
    )
RETURN
    TotalEstimate / MaxSectionSequence

 

The output is as shown below:

DataNinja777_0-1725461467250.png

I have attached a sample pbix file for your reference.

Best regards,

 

That did work, but now it only shows the average when I remove the stop sequence number.  How do I get it to sum to the original amount when the stop sequence number is removed and have the total line to show the original total versus the line item amount?

 

With Stop Sequence

cheid_4838_0-1725462778315.png

Without Stop Sequence

cheid_4838_1-1725462818242.png

 

Hi @cheid_4838 ,

How about updating the measure as shown below?

Average Estimate by Max Section Sequence (update) = 
VAR MaxSectionSequence = 
    CALCULATE(
        MAX('Table'[Section Sequence]), 
        ALLEXCEPT('Table', 'Table'[PO Number])
    )
VAR TotalEstimate =
    CALCULATE(
        max('Table'[Estimate]), 
        ALLEXCEPT('Table', 'Table'[PO Number])
    )
RETURN
   sumx('Table', TotalEstimate / MaxSectionSequence)

 

The output is shown below:

DataNinja777_0-1725496344990.png

I have attached a sample pbix file.

 

Thanks for your help.  I learn something all the time from this site.  

sroy_16
Resolver II
Resolver II

Hello @cheid_4838 

Try using these measure for the solution.
Create a new measure to calculate the total estimated cost for each repair order:
TotalEstimatedCost = SUM(TableName[EstimatedCost])

Create a measure to count the number of lines (or section sequences) for each repair order:

LineCount = COUNTROWS(
FILTER(
TableName,
TableName[RepairOrderID] = MAX(TableName[RepairOrderID])
)
)

Create a measure to calculate the estimated cost per line:

CostPerLine = DIVIDE(
[TotalEstimatedCost],
[LineCount],

)

 

Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Unfortnately that didn't work because it summed the estimated cost (below) to get a total of $8,681.12.  Then divided that total by the line count to get the original amount of $4,340.56. I want to take $4,340.56 and  divide it between the number of lines per order.  I need to some how get around having to sum the estimated cost.

 

cheid_4838_0-1725461595204.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.