As you may know, when a filter is applied to a range of values in MS Excel, COUNTIF statements applied to that range do not get altered to reflect the filtered values displayed. Consider the example below where I have indicated all unique Order Dates in column C and summed up the number of unique orders in cell H1. (Note: The formula used in cell H1 is "=COUNTIF(C2:C25, 1)" Now lets apply a filter to this range and see the outcome in cell H1. For the purpose of this example, I will deselect order dates belonging to January 1st, 2nd and 3rd in the filter. As could be observed in the screenshot below, the value in cell H1 does not represent the correct sum of unique order dates of the data displayed, rather it represents the sum of all values originally selected before applying the filter. In order to Modify our formula to represent the filtered values, the steps below must be undertaken: First, we must create an additional column (column D) in which the SUBTOTAL formula has to be applied to the order numbers (to be applied to the entire range. i.e. from D2 to D25). This column is necessary for the next step as it will help identify those cells which were suppressed through the filter selection. Click here if you want to learn more about the SUBTOTAL formula in MS Excel. Second, we must create a second tab on the spreadsheet (i.e. Tab2). This new tab will contain two columns.
Last but not least, I will go to the original tab (i.e. Tab1) in the spreadsheet and revise the formula in cell H1 to represent the unique order numbers depicted in tab2 of the spreadsheet. By entering this formula, the value in cell H1 will represent the sum of those unique order numbers which have been displayed after applying the filter and the suppressed cells will no longer be counted.
1 Comment
|
CategoriesArchives
June 2020
|