Forum Discussion

randyvdr's avatar
randyvdr
Frequent Visitor
1 year ago
Solved

total Value with repeated rows

Hello Communitiy,

 

Would you be so gentle to help me with the following query.

 

I have the next example set of data:

 

RegionCountryCategory IDSales order IDTotal Sales
EUROPEItalyAE10 $                    100.00
EUROPEItalyAE10 $                    100.00
EUROPEItalyB  
EUROPEGermanyCE20 $                    150.00
EUROPENorwayDE30 $                    200.00
EUROPENorwayEE30 $                    200.00
ASIAThailandDAS10 $                    300.00
ASIAThailandEAS10 $                    300.00
ASIAJapanGAS20 $                    275.00
ASIAJapanHAS30 $                    225.00
ASIAKoreaIAS40 $                    215.00
ASIAKoreaIAS40 $                    215.00
AFRICANigeriaK  
AFRICANigeriaK  
AFRICAAngolaLAF10 $                    520.00
AFRICAKenyaMAF20 $                    512.00

 

As you can see I have repeated rows of Total Sales, my output should be as following:

 

Sales Order IDTotal_sales_calc
E10 $           100.00
E20 $           150.00
E30 $           200.00
AS10 $           300.00
AS20 $           275.00
AS30 $           225.00
AS40 $           215.00
AF10 $           520.00
AF20 $           512.00
Total $        2,497.00
  • Hi, 

     

    Please try the following:

    Sales calc = SUMX(SUMMARIZE('Table', 'Table'[Sales order ID], 'Table'[Total Sales]), 'Table'[Total Sales])

    Note - for this to work, i assume that each combination of sales order ID and total sales is unique. If you end up with a row that's like:

    Region Country Category ID Sales order ID Total Sales
    EUROPE Italy A E10  $                    100.00
    EUROPE Italy A E10  $                    200.00

    then the result in your table will show $300. If this is not the result that you expect, then you will need to provide more details on how you expect to handle this case.

4 Replies

  • Hi, 

     

    Please try the following:

    Sales calc = SUMX(SUMMARIZE('Table', 'Table'[Sales order ID], 'Table'[Total Sales]), 'Table'[Total Sales])

    Note - for this to work, i assume that each combination of sales order ID and total sales is unique. If you end up with a row that's like:

    Region Country Category ID Sales order ID Total Sales
    EUROPE Italy A E10  $                    100.00
    EUROPE Italy A E10  $                    200.00

    then the result in your table will show $300. If this is not the result that you expect, then you will need to provide more details on how you expect to handle this case.

  • Hi,

    These measures work

    Min sale = MIN(Data[Total Sales])
    Measure = SUMX(VALUES(Data[Sales order ID]),[Min sale])

    Hope this helps.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi @ randyvdr,

     

    Thanks to the two Super Users Ashish_Mathur , vicky_ for their responses.


    You can also try the following DAX to create the Total_sales_calc measure.

    Total_sales_calc = 
    SUMX(
        DISTINCT('Sales'[Sales order ID]),
        CALCULATE(MAX('Sales'[Total Sales]))
    )

     

     

    Best Regards,

    Dengliang Li

     

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

  • randyvdr's avatar
    randyvdr
    Frequent Visitor

    Hello community, thanks for all your fast reponses, the results from all three formulas are the following:

     

    vicky_  & Anonymous  the answers are as expected