Forum Discussion

twofingertyper's avatar
twofingertyper
Helper III
1 year ago
Solved

Two tables, differing data - merge, append new or other?

Hi all, 


I have two tables - one that runs for a longer period (AllSales) and one that is shorter, but captures cancelled sales (SalesStatus). 

They do not have identical columns, but both have a SalesOwnerID that can be used to pair things up. 

My question is how would I pull ALL SalesOwnerID (both historic sales, and those that have been cancelled) so I can review and perform calculations on them? 

 

I thought about appending, but that leaves rows with lots of null values (and as the tables combined are 1m rows plus it's rather data heavy), or carrying out a merge, but if I merge on SalesOwnerID I am still not getting all of the sales through for some reason. 

 

For example:

All Sales has

SalesOwnerIDDateStatusValueProductIDUniqueID
00112/02/24Complete40001120224-001-001
00212/03/24Complete5001130324-002-001
00115/03/24Dispatched 20001150324-001-001

 

SalesStatus has:

SalesOwnerIDDateStatusProductIDUniqueID
00113/02/24Cancelled001130224-001-001
00110/10/24Pending001101024-001-001
00115/03/24Dispatched 001150324-001-001

 

I would like the end result to be simply for SalesOwner 001

SalesOwnerIDDateStatusValueProductIDUniqueID
00112/02/24Complete40001120224-001-001
00113/02/24Cancelled 001130224-001-001
00115/03/24Dispatched 20001150324-001-001
00110/10/24Pending 001101024-001-001

 

If I merge on SalesOwnerID it's not adding in new rows for that ID, and if I append into new I end up with numerous rows with blanks included (I could calculate columns but it seems rather resource heavy for something that should be easier). 

 

Is there a simple trick/method I am overlooking?

  • lbendlin's avatar
    lbendlin
    1 year ago
    let
        Source = #"All Sales" & #"Sales Status",
        #"Grouped Rows" = Table.Group(Source, {"SalesOwnerID", "Date", "Status", "ProductID", "UniqueID"}, {{"Value", each List.Sum([Value]), type nullable number}})
    in
        #"Grouped Rows"

     

     

8 Replies

  • Your data is ambiguous as you don't know for sure what the cancellation is for.  At a minimum you need to add an order ID column.

    • twofingertyper's avatar
      twofingertyper
      Helper III

      Sorry! There is a productid associated too (amongst other things) - I was just trying to get across my data without it being overkill. 

      Let's just assume that all orders above are for the same product. 

  • based on the sample data you provided, what we can do is to append both tables. I don't not understand why end up with numerous rows with blanks? 

    maybe you need to update your sample data?

    • twofingertyper's avatar
      twofingertyper
      Helper III

      Sorry - again an issue with being too brief with my data sample and corrected in the above now. 

       

      Essentially you may get records that appear in BOTH tables, and in that case the append obviously duplicates records (one with, one without value). 


      The actual data is years of history so I need to keep transformations as light as possible. 

      • lbendlin's avatar
        lbendlin
        Super User

        Still not enough data to disambiguate. You will need to know which order a cancellation is for.