Remove Duplicate Lines whille Retaining Total from (or Sum of) Adjacent Column

zgadson

Board Regular
Joined
Jul 16, 2015
Messages
68
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello! Stumped as usual on something I've unintentionally made overly complex. I have a Concatenated field LTRIM(CONCAT(MAAISL,MASLOT)) AS LOCATION that I need to use as a group. I also need to SUM the CASE WHEN line based on the group.

Goal: Eliminate duplicate values in the LOCATION column while retaining the total from the last PLT.QTY column per the yellow highlights in my worksheet. IE, Location "A1 7D" = 2 pallets, and "A1 8D" = 2 pallets.

Here's what I've got:

SELECT LTRIM(CONCAT(MAAISL,MASLOT)) AS LOCATION, LTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(MASLOT, 'A', ''), 'B', ''), 'C', ''), 'D', ''), 'E', ''), 'F', ''), 'G', ''), 'H', ''), 'I', ''), 'J', ''), 'K', '')) AS "SLOT.NUM", LTRIM(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(MASLOT, '0', ''), '1', ''), '2', ''), '3', ''), '4', ''), '5', ''), '6', ''), '7', ''), '8', ''), '9', '')) AS "SLOT.LVL", LTRIM(MAWHSE) AS WHSE, LTRIM(MAAISL) AS AISLE, LTRIM(MASLOT) AS SLOT, LCSTOR, STNAME, LTRIM(ITDSC1) AS "ITM.DESC", LTRIM(LCITEM) AS "ITM.CODE", LTRIM(ITPDCD) AS FAMILY, CASE WHEN ITUNQ3 = 0 THEN CEIL(QTY/ITUNQ2) ELSE CEIL(QTY/ITUNQ2/ITUNQ3) END AS "PLT.QTY", LTRIM(MADEPT) AS DEPTH, CEILING(ITINDP) AS "ITM.DPTH", CEILING(ITINWD) AS "ITM.WDTH", CEILING(ITINHI) AS "ITM.HGHT", CEILING(ITPALH) AS "PLT.STACK.HGHT" FROM LOCXSTORER
 

Attachments

  • Untitled.png
    Untitled.png
    16.2 KB · Views: 18

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,762
Messages
6,174,353
Members
452,557
Latest member
savvaskef

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top