Consolidate Table To Remove Blank values month by month

asharris90

New Member
Joined
Oct 31, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

having a real challenge trying to solve this so hope someone can help. I have the attached table and what I now want to do is consolidate the table into a new table so that it removes any customer rows that have 0’s within the whole year period. So only keeping customers that have an order value at some point in the year ensuring to return their order value in the same month.
Finding it hard to describe what I mean so I hope this makes sense and thanks in advance.
 

Attachments

  • 846905CB-03E3-4F4B-80C3-D3171C7D7E63.png
    846905CB-03E3-4F4B-80C3-D3171C7D7E63.png
    208 KB · Views: 12

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this code on a COPY of your worksheet
VBA Code:
Sub ConsRemBlnk()
Dim i, j, lr As Long

lr = Cells(Rows.Count, "B").End(xlUp).Row

For i = lr To 5 Step -1
    If WorksheetFunction.Sum(Range("C" & i & ":N" & i)) = 0 Then
        Cells(i, 1).EntireRow.Delete
    End If
Next i

End Sub
 
Upvote 0
use Power Query (Get&Transform)
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Leading0 = Table.AddColumn(Source, "Customer", each Text.PadStart(Text.Select([BP], {"0".."9"}),2,"0")),
    Customer = Table.AddColumn(Leading0, "Custom", each Text.Select([BP], {"a".."z","A".."Z", " ", "-"})),
    Replace = Table.ReplaceValue(Customer,"00","",Replacer.ReplaceText,{"Customer"}),
    RC = Table.RemoveColumns(Replace,{"BP"}),
    TCC = Table.CombineColumns(RC,{"Custom", "Customer"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"BP"),
    Unpivot = Table.UnpivotOtherColumns(TCC, {"BP"}, "Attribute", "Value"),
    Filter = Table.SelectRows(Unpivot, each ([Value] <> 0))
in
    Filter
then Close&Load
 
Upvote 0
Solution
I forgot to say, you'll need to change your source Table a bit because of your double headers
BPApril 2020May 2020June 2020July 2020August 2020Septembe 2020October 2020November 2020December 2020January 2021February 2021March 2021
Customer 1000000000000
Customer 2000000000000
Customer 3000000000000
Customer 4000000000000
Customer 5000000000000
Customer 6000000000000
Customer 74500000000000000
Customer 80300000000000000
Customer 90003400000000000
Customer 1000000350000000000
Customer 110000015000000000
Customer 1200000317000000000
Customer 130000003000000000
Customer 140000009000000000
Customer 150000000900000000
Customer 1600000007340000000
Customer 170000000065000000
Sagentia Ltd - C00000000036000000
 
Last edited:
Upvote 0
use Power Query (Get&Transform)
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Leading0 = Table.AddColumn(Source, "Customer", each Text.PadStart(Text.Select([BP], {"0".."9"}),2,"0")),
    Customer = Table.AddColumn(Leading0, "Custom", each Text.Select([BP], {"a".."z","A".."Z", " ", "-"})),
    Replace = Table.ReplaceValue(Customer,"00","",Replacer.ReplaceText,{"Customer"}),
    RC = Table.RemoveColumns(Replace,{"BP"}),
    TCC = Table.CombineColumns(RC,{"Custom", "Customer"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"BP"),
    Unpivot = Table.UnpivotOtherColumns(TCC, {"BP"}, "Attribute", "Value"),
    Filter = Table.SelectRows(Unpivot, each ([Value] <> 0))
in
    Filter
then Close&Load
Perfect thank you
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,566
Members
449,089
Latest member
Motoracer88

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