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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
grega
Helper II
Helper II

Summarise Non Unique Values

Hi,

 

I have a problem that I hope someone will be able to help me with.

I need to summarise a table containing the Customer Name, Order Number, Stock Reference, Cost Price, Sale Price, and Margin Percentage.

 

If the Cost Price and the Sale Price are identical and there are multiple rows for the order I want to summarise it into one row by Order number.  Here is a data example:

 

Customer NameOrder NumberStock ReferenceCost PriceSale PriceMargin %
AB Smith2354KPCB_147681536.3758.76
AB Smith2354KPCB_147681536.3758.76

 

However if there is an order that has multiple rows but different Cost/Sale Prices I don't want to summarise that data.  Here is an example:

 

Customer NameOrder NumberStock ReferenceCost PriceSale PriceMargin %
T K Anderson2355BS10_5467417.532.9654.49
TK Anderson2355BS09_34889194052.5

 

I hope this makes sense.

 

Thanks for your help,

Greg.

10 REPLIES 10
FreemanZ
Super User
Super User

hi @grega 

not sure what column do you want to summarize. Let me suppose you want the general Margin%, then try like:

Margin% = 
VAR _table = 
    SUMMARIZE(
        TableName,
        TableName[Customer Name],
        TableName[Order Number],
        TableName[Stock Reference],
        TableName[Cost Price],
        TableName[Sale Price]
    )
RETURN
1 - 
DIVIDE(
    SUMX(_table, TableName[Cost Price]),
    SUMX(_table, TableName[Sale Price])
)

 

Hi

 

Thanks for the reply.

 

I'm trying to summarise all the columns if multiple rows are itentical for an order.  So if you have multiple rows where the Cost Price, Sale Price and Margin % are the same, sumarise.  If there are orders where the Cost Price, Sale Price and Margin % on an order are different I don't want to summarise.  I hope that is clear.

 

Thanks,

Greg.   

If there are   

hi @grega 

still quite unclear. could you post your expected result?

Hi,

 

Sure, I'm probably not explaining this very well.  With regard to the identical rows.  I don't actually want to sum the values of the identical rows.  I only want one row from multiple rows.  For example, If I originally have this:


Id             Cust Name           Order No  Stock Reference          Cost Price Sales Price  Margin %

1AB Smith2354KPCB_147681536.3758.76
2AB Smith2354KPCB_147681536.3758.76
3AB Smith2354KPCB_147681536.3758.76

 

I need this:

 

IdCust NameOrder NoStock ReferenceCost PriceSale PriceMargin %
1AB Smith2354KPCB_147681536.3758.76

 

Also, anything that is not a duplicate needs to display all the rows for the order, etc.

 

I hope this clears things up.

 

Thanks,

Greg. 

Sorry, the table did not come out very well.  Try these

 

Before:

 

IdCust NoOrder NoStock RefCost PriceSales PriceMargin %
1AB Smith2354KPCD_147681536.3758.76
2AB Smith2354KPCD_147681536.3758.76
3AB Smith2354KPCD_147681536.3758.76

 

After:

 

IdCust NoOrder NoStock RefCost PriceSale PriceMargin %
1AB Smith2354KPCD_147681536.3758.76

 

Thanks,

Greg.

or you plot a table visual with all the needed column and choose "min" for the id colum and "don't summarize" for all other columns

FreemanZ_5-1678094733458.png

 

Hi,

 

Ok, will have a look, I think think this will work.

 

Thanks,

Greg.

hi @grega 

try to create a calculated table with:

 

Table = 
ADDCOLUMNS(
    SUMMARIZE(
        TableName,
        TableName[Cust No],
        TableName[Order No],
        TableName[Stock Ref],
        TableName[Cost Price],
        TableName[Sales Price],
        TableName[Margin %]
    ),
    "ID",
    CALCULATE(MIN(TableName[Id]))
)

FreemanZ_0-1678094397617.png

 

 

 

lbendlin
Super User
Super User

use DISTINCT()

Thanks.  

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.