Here's one way:
Table 1 ("Data") is a simplified version of your example table.
Table 2 ("W") shows the purchases made at store W.
Data requires an added column, "index", which is a 'working' column, necessary to the action, but not to the eye. it may be hidden.
There is one formula used to create the index:
E2, and filled down: =D&COUNTIF($D$2:D2,D)
The table "W" also contains one formula, entered into A2, and filled down column A, and rigth to column D. Note that if you define column A as a header column, it will be necessary to Copy A2, then select B2 and go Edit > Paste and Match Style to get the formula across the boundary between Header column and Body columns. From B2, it can be filled down and Right to D14 (or further down, depending on the number of purchases from W).
A2, and filled down, B2, and filled down and right: =IFERROR(OFFSET(Data :: $A$1,MATCH($A$1&ROW()-1,Data :: $E,0)-1,COLUMN()-1),"")
Duplicate the table W for each store from which you have purchased, then replace the name "W" in A1 of the duplicate table with the name of a different store.
Regards,
Barry