Apr 19 2023 02:06 AM - edited Apr 26 2023 03:06 AM
Hi,
I have a table with rep contacts on different product topics on different days to the same customer as below which are on different rows dependent on the date. Is there a formula that I could us to combine the rows by customer but still retain the date for each product topic. Thanks in advance.
Apr 19 2023 02:50 AM - edited Apr 19 2023 03:24 AM
You have a table in Excel with multiple rows for the same customer and you want to combine these rows into one row per customer while retaining the dates for each product topic. Is that correct?
If so, one way to achieve this is by using a PivotTable.
A PivotTable allows you to summarize and organize your data based on specific criteria. In your case, you could create a PivotTable with the Account column as the Rows field and the Product columns as the Columns field. This would group all the rows for each customer together and display the dates for each product topic in separate columns.
It is possible to use formulas to combine rows by customer while retaining the date for each product topic, but it can be quite complex and may require the use of multiple formulas and helper columns. Using a PivotTable, as described, is a simpler and more straightforward way to achieve the desired result.
Apr 19 2023 09:07 AM
Apr 19 2023 09:18 AM
If you run Excel >/= 2016 / Windows there's probably something to do with Get & Transform aka Power Query
Glad to have a look at this if you can share a representative workbook + an example of the expected result as I must admit it's not clear to me
Apr 20 2023 12:03 AM
Apr 20 2023 12:08 AM
Apr 20 2023 01:13 AM
Apr 24 2023 01:25 AM
Hi,
I found that the pivot table was throwing out some incorrect results so I started again.
I've used the phrase table a couple of times but I mean the cells with the relevant info. I haven't actually formated or created any tables.
I started by sorting my imported data from an import sheet onto a separate worksheet into date order with the newest results at the top so that an Xlookup would always return the newest result.
=SORT(FILTER(A2:D7001,A2:A7001<>""),4,-1)
I then referenced the sorted data above as below and used helper rows to add a searchable index code.
in cell L2 =IF(F2="","",F2) F2 being the account number on the sorted table above
cell O2 =IF($H2=O$1,$I2,"")
H2 being the 1st result from the sorted table above that is matches the topic in O1 in the table below.
Index code in cell N2 =IF(O2="","",$L2&O$1)
I was then able to consolidate everything into 1 unique table showing only the newest contacts per customer per topic as below.
Cell AI =SORT(UNIQUE(FILTER(L2:L7001,L2:L7001<>"")))
Cell AK2 =XLOOKUP($AI2&AK$1,N:N,O:O,"")
Cell AK3 =XLOOKUP($AI2&AL$1,P:P,Q:Q,"")
And so on and then the date of the latest contact in Cell AU2
=IF(SUM(AK2:AT2)<=1,"",MAX(AK2:AT2))
I then created 2 lists AX1 to AX9 and AZ1 to AZ3 to use as sort options on a results worksheet.
AY1 to AY9 is the column to sort by and BA1 to BA3 is the sort order.
BC1 references a dropdown on the results worksheet then looks up the number to use in the sort function
=XLOOKUP(Results!O2,Worksheet!AX1:AX12,Worksheet!AY1:AY12)
BC2 does the same to find the other number to use in the same sort function
=XLOOKUP(Results!R2,Worksheet!AZ1:AZ3,Worksheet!BA1:BA3)
This then gives me the table below that can be sorted by topic / account / last contact etc and sort order by selecting the options in the dropdown in O2 and R2.
I've hidden the account names for data confidentiality reasons. I hope I've explained this well.
Apr 24 2023 01:33 AM
Apr 25 2023 10:30 AM
Apr 26 2023 12:18 AM
Apr 26 2023 01:02 AM
Hi @AndyT410
This doesn't well answer my questions (might be my fault) so let's see if the attached Power Query approach goes in the right direction
- Table 'Import' is the content of your 'Import' sheet formatted as Table
- Table 'Result' reflects what I understood in terms of expected result
Let me know where I missed something/what's wrong
Apr 26 2023 01:16 AM
Apr 26 2023 01:43 AM
The result should be the company listed only once down the table with the most reason contact per topic listed across the rows
- company listed only once Then how do you expect to represent i.e. Company 12 that has [Account Number] 1245 and 1246 and 1246?
- most reason contact Does this mean Most recent [Call Made On]?
Apr 26 2023 02:18 AM
Apr 26 2023 02:52 AM
Could you check the attached query and let me know what's wrong/missing?
Apr 26 2023 03:10 AM
Apr 26 2023 04:15 AM
Looks right to me, Just need the last contact column. I've deleted the old and reattached an amended base sample
Well, I'm not going to do the job twice as in the last workbook I shared I already fixed the [Customer]s that had several [Account Number]s (i.e. Customer 12). That said no problem to add a [Last Contact] column if you wish but...
IF the Power Query option I shared does it, you shouldn't need it. I haven't checked all but in the attached workbook you'll find in 'PQ vs PVT' the output of the query vs. a PivotTable. A quick comparison gives me the impression they produce the same results and by activating the Grand Total fos rows you get the extra column you expect. Last but not least a Pivot Table approach will be more efficient
Let me know your thoughts and any issue
Apr 26 2023 04:22 AM