View Single Post
 
Old 01-02-2024, 07:41 AM
FlightRisk FlightRisk is offline Windows 11 Office 2021
Novice
 
Join Date: Jan 2024
Posts: 2
FlightRisk is on a distinguished road
Default Invoice merge grouping items on same order number with NEXTIF skipping every other order

Hi. New here and out of my league. Watched many videos and tried Paul's excellent tutorials in the sticky and searched here. I've even looked at the many to one plugin and solutions that use "DATABASE", but perhaps I am close since it works other than skipping ever other new order number.

I have a CSV file that comes to me in a format like this:

Code:

Order ID  First Name  Last Name  Shipping Total  Order Total  Product Title
444453    Jack           Smith           6.2                  91.2           Motor Board
444453					                                             Motor Board
444453					                                             WiFi Board
444453                                                                                 Expander Board
444454   John            Doe           4.99                  44.89       Motor Board
444455   Bob             Bobbly     13.64	             95.44        Motor Board
444456   Shawn	    Payton      5.64                  83.44        Motor Board

The table in the Word Invoice would obviously group all the things by order ID and put them in the appropriate cells, total things, and then merge into their "individual documents". Order 1 (444453) merges and puts each record in the correct line item for it's document, but then it skips the next order number, does the next one correctly, skips the next one, and so on.

The "NEXTIF" sections in the table look like this (simplified without some totaling fields):

Code:
{ MERGEFIELD Model_Number}
{ MERGEFIELD Product_Title }
{SET ID1 "{MERGEFIELD Order_ID}"

The next row in the table has:

{ NEXTIF{ MERGEFIELD Order_ID } = { ID1 }}{SET ID2"{MERGEFIELD Order_ID}"}{IF ID1 = ID2 "{MERGEFIELD Quantity}" ""}
The above is pasted again and again in each row in the table to cover a maximum of 6 items per order. This is just the QTY field, but the description is next, then amount, etc.

I am thinking I need to reset ID1 or ID2 somewhere possibly? I have attached small, simplified demo versions of the CSV data file (as a text file since this forum won't accept CSV files) and the Word mailmerge template. I think it is just a "letter", not a "directory", but still trying to learn what the difference is and if it is important since I think it is working except for my logic flow. Thank you!
Attached Files
File Type: docx test_merge.docx (115.4 KB, 4 views)
File Type: txt orders_test.txt (1.8 KB, 4 views)

Last edited by FlightRisk; 01-02-2024 at 07:51 AM. Reason: trying to get table entries to line up
Reply With Quote