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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
GabrielFz
Frequent Visitor

Combining duplicate rows and add column for different values

Hi,

 

I'm trying to get unique rows for one of my Data Sources. The data looks like this:

 

GabrielFz_3-1592912905019.png

 

 

And I would like to get a table like this:

GabrielFz_4-1592912929611.png

 

 

Notes:

On my original data, not every product has 2 lines

I have several columns with this same purpose, so I would like a solution that will work on a bigger database

 

Thanks in advance (:

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@GabrielFz , create a new table like

	summarize(														
selectcolumns(Table,"Product", Table[product],"Quantity A",if(Table[Location] ="A",Table[Quantity],blank())
											,"Quantity B",if(Table[Location] ="B",Table[Quantity],blank())
											,"Delivery Date A",if(Table[Location] ="A",Table[Delivery Date],blank())
											,"Delivery Date B",if(Table[Location] ="B",Table[Delivery Date],blank())
											,"Color", table[Color]),[product],[Color],"Quantity A",sum([Quantity A]),"Quantity B",sum([Quantity B])
											,"Delivery Date A",max([Delivery Date A]),"Delivery Date B",Max([Delivery Date B]))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Icey
Community Support
Community Support

Hi @GabrielFz ,

 

Based on my test, the expression @amitchandak provided is a bit problematic. Please modify it like so:

Table 2 =
VAR t =
    SELECTCOLUMNS (
        'Table',
        "Product", 'Table'[product],
        "Quantity A", IF ( 'Table'[Location] = "A", 'Table'[Quantity], BLANK () ),
        "Quantity B", IF ( 'Table'[Location] = "B", 'Table'[Quantity], BLANK () ),
        "Delivery Date A", IF ( 'Table'[Location] = "A", 'Table'[Delivery Date], BLANK () ),
        "Delivery Date B", IF ( 'Table'[Location] = "B", 'Table'[Delivery Date], BLANK () ),
        "Color", 'Table'[Color]
    )
RETURN
    SUMMARIZE (
        t,
        [product],
        [Color],
        "Quantity A", SUMX ( t, [Quantity A] ),
        "Quantity B", SUMX ( t, [Quantity B] ),
        "Delivery Date A", MAXX ( t, [Delivery Date A] ),
        "Delivery Date B", MAXX ( t, [Delivery Date B] )
    )

t1.PNGt2.PNG

 

 

Best Regards,

Icey

 

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

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @GabrielFz ,

 

Based on my test, the expression @amitchandak provided is a bit problematic. Please modify it like so:

Table 2 =
VAR t =
    SELECTCOLUMNS (
        'Table',
        "Product", 'Table'[product],
        "Quantity A", IF ( 'Table'[Location] = "A", 'Table'[Quantity], BLANK () ),
        "Quantity B", IF ( 'Table'[Location] = "B", 'Table'[Quantity], BLANK () ),
        "Delivery Date A", IF ( 'Table'[Location] = "A", 'Table'[Delivery Date], BLANK () ),
        "Delivery Date B", IF ( 'Table'[Location] = "B", 'Table'[Delivery Date], BLANK () ),
        "Color", 'Table'[Color]
    )
RETURN
    SUMMARIZE (
        t,
        [product],
        [Color],
        "Quantity A", SUMX ( t, [Quantity A] ),
        "Quantity B", SUMX ( t, [Quantity B] ),
        "Delivery Date A", MAXX ( t, [Delivery Date A] ),
        "Delivery Date B", MAXX ( t, [Delivery Date B] )
    )

t1.PNGt2.PNG

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@GabrielFz , create a new table like

	summarize(														
selectcolumns(Table,"Product", Table[product],"Quantity A",if(Table[Location] ="A",Table[Quantity],blank())
											,"Quantity B",if(Table[Location] ="B",Table[Quantity],blank())
											,"Delivery Date A",if(Table[Location] ="A",Table[Delivery Date],blank())
											,"Delivery Date B",if(Table[Location] ="B",Table[Delivery Date],blank())
											,"Color", table[Color]),[product],[Color],"Quantity A",sum([Quantity A]),"Quantity B",sum([Quantity B])
											,"Delivery Date A",max([Delivery Date A]),"Delivery Date B",Max([Delivery Date B]))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.