Forum Discussion

daicaboy's avatar
daicaboy
Helper I
3 years ago
Solved

Return Mutilple result in one row

Dear all, 

I've have a Data 1

Data 1

ProductSupplierQuantity
ComputerAA2
ComputerBB5
PhoneCC6

and i want to make a report by power query with Mutiple Supplier and the Most sell:

Report

ProductSupplierSupplierThe Most sell supplier
ComputerAABBBB
PhoneCC CC

Can anyone help me with that.

Thanks you!

  • NewStep= Table.Combine(Table.Group(Data1,"Product",{"n",each let a=Table.Group(_,"Supplier",{"n",each List.Sum([Quantity])}) in Table.FromRows({{[Product]{0}}&a[Supplier]&{Text.Combine(Table.SelectRows(a,each [n]=List.Max(a[n]))[Supplier],",")}},{"Product"}&List.Transform(List.Positions(a[n]),each "Supplier "&Text.From(_+1))&{"Most Sell Suppliers"})})[n])

2 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    NewStep= Table.Combine(Table.Group(Data1,"Product",{"n",each let a=Table.Group(_,"Supplier",{"n",each List.Sum([Quantity])}) in Table.FromRows({{[Product]{0}}&a[Supplier]&{Text.Combine(Table.SelectRows(a,each [n]=List.Max(a[n]))[Supplier],",")}},{"Product"}&List.Transform(List.Positions(a[n]),each "Supplier "&Text.From(_+1))&{"Most Sell Suppliers"})})[n])