Forum Discussion

ktbam_7's avatar
ktbam_7
New Member
2 years ago
Solved

Line Item sum for unique label

Hello,

 

I have below sample data and need a measure to calculate a sum of each unique package label based on the individual package IDs:

 

Package LabelPackage IDLine Item Cost
455571110$995.95
455571118$493.00
455571119$948.05

 

I need an outcome like this:

 

Package LabelPackage IDLine Item CostTotal Package Cost
455571110$995.95$2,437.00
455571118$493.00$2,437.00
455571119$948.05$2,437.00

 

I have tried the below in DAX, but the measure just returns the line item cost again:

 

Unique Package Label Costs = SUMX(VALUES('table'[package label]),CALCULATE(SUM('table'[line item cost])))
Unique Package Lable Costs = SUMX(DISTINCT('table'[package label]),CALCULATE(SUM('table'[line item cost])))

 

Thanks,

Alex

 

 

  • Hi,

    Please check the below picture and the attached pbix file.

     

     

     

    Total package cost: =
    CALCULATE (
        SUM ( 'table'[Line Item Cost] ),
        ALLEXCEPT ( 'table', 'table'[Package Label] )
    )
    

4 Replies

  • powerbiexpert22's avatar
    powerbiexpert22
    Icon for Impactful Individual rankImpactful Individual

    Hi ktbam_7 

    please try below

     

    CALCULATE(SUM(table[Line Item Cost]),FILTER(All(table),
    table[Package Label]=MAX(table[Package Label])))
    • ktbam_7's avatar
      ktbam_7
      New Member

      This worked as well! Thank you.

  • Hi,

    Please check the below picture and the attached pbix file.

     

     

     

    Total package cost: =
    CALCULATE (
        SUM ( 'table'[Line Item Cost] ),
        ALLEXCEPT ( 'table', 'table'[Package Label] )
    )