Solved

Filter by Row in Excel (Part 2 - Efficiency!)

Posted on 2014-02-16
7
382 Views
Last Modified: 2014-02-18
I previously asked a query on Filtering by a value in a Row, rather than a column:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_28363142.html#a39856514

"I would like a way, if possibly, to filter through this by ROW, rather than Column.

For example, in each group we have a Row labelled Responsibility Application. I want to Filter by Responsibility Application ."

This was answered perfectly by user: byundt

Attached is a working example:  ExpertsExchangeExample2Q28363142.xlsm

This solution works perfectly for a dataset of about 5000 rows or less. It takes 40-50 seconds to calculate, but works and is usable.

However, I have been given the same task on a file with 25,000 rows. This solution of filtering by Row causes Excel and the laptops in question to almost break down, so unfortunately can be used.

Can anyone, byundt included, come up with a way to run this or a solution that will work on very large data sets?

Thank you,

Alex
0
Comment
Question by:EllenExcel
7 Comments
 

Author Comment

by:EllenExcel
ID: 39863335
I'm attaching a blank example (with just data, not the previous solution):

ExpertsExchangeExample2.xlsm.xlsx
0
 
LVL 21

Assisted Solution

by:Ejgil Hedegaard
Ejgil Hedegaard earned 125 total points
ID: 39863421
Smart solution.

Computations for entire columns take a long time.
If the search is narrowed down to just done when a new section starts,
(Col A=Responsibility), and only looking at a smaller range.

For column D, the numbering.
I have changed to numbers, to use the Max function, only performed when a new block start.
For D6, copied down.
=IF(A6="","",IF(A6="Responsibility",MAX(D$5:D5)+1,D5))

Open in new window


For Column E, Result True/False, only looking 100 rows down
For E6, copied down
=IF(D6="","",IF(A6="Responsibility",(COUNTIFS(D6:D105,D6,A6:A105,A$2,B6:B105,B$2)+COUNTIFS(D6:D105,D6,A6:A105,A$2,C6:C105,B$2))>0,E5))

Open in new window


With 4.500 rows it just takes a second.
See file
Filter-by-row.xlsm
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 125 total points
ID: 39863538
Another approach, relying wholly on VBA:

Q-28366250.xlsm

Use A2:B2 to change what field you filter, and what value you seek for that field.

Note the following:
Code looks at key values in Columns B:???.  To control how many columns are being used, change the NumColumns constant
If the value being sought is found anywhere in those columns, the item is kept (i.e., not hidden)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 80

Accepted Solution

by:
byundt earned 125 total points
ID: 39863921
Alex,
I had thought of restricting the range in the MAX and COUNTIFS functions in your original question, but chose not to in the interest of simplicity. To take advantage of these formula improvements, you would need to specify both the maximum "gap" between records and the maximum number of rows possible in a "record".

hgholt has already suggested a suitable improvement for the COUNTIFS formula in column E. He assumed no more than 100 rows in a record.

Here is an improved MAX formula in cell D6 (should be copied down). It assumes there are no more than four blank rows between records.
=IF(A6="","",IF(A6="Responsibility",MAX(D1:D5)+1,D5))

With 26,000 rows of data, the macro found a single record located near the end of the list in a couple of seconds on my six  year old Macintosh running Windows in emulation. No change in macro code was necessary.


If this were my workbook, I would be thinking about putting each record on a single row. The more you analyze the data, the more firmly I feel such a change would be needed. Putting each record on a single row would mean that each of the different fields would be in its own column. A macro to remap the data wouldn't be hard to write.

Brad
0
 
LVL 2

Assisted Solution

by:c_kedar
c_kedar earned 125 total points
ID: 39864470
See attached.

Type the FieldName by which you want to filter in B1 i.e. "Responsibility Name"
column D will be populated.

Use filter in D3 to filter by value of the FieldName you have selected.

The formula for populating D, in D4 is
=IF(A4="Responsibility", VLOOKUP($B$1, A4:B999,2,FALSE), D3)

Open in new window



Here is the explanation for the same:
A4="Responsibility" => Detect first row of the block of of rows constituting one record
VLOOKUP($B$1, A4:B999,2,FALSE) => Value of selected FieldName in this record. 999 here is arbitrary, should be greater or equal to max no of rows in a record.
D3 => Cell above

Logic: If it is start of the block, then set cell to value of selected key in the record, for subsequent rows, simply copy the value set above.

Note: If selected field is not present in a record but present in subsequent record that is covered in next 999 rows, then result will be erroneous.
There is more complex formula in column E which solves this issue but has problem with last record. This can be solved by ensuring an empty record at the end, i.e. insert "Responsibility" in in A142.
Filter-By-Row-Solution.xls
0
 

Author Closing Comment

by:EllenExcel
ID: 39866855
All of your solutions work, so I've spread the points across the lot.

Thanks all for the comments - Brad you are right it would be much simpler to transpose everything up to a column view looking at it.

I wanted this solution because who this is for preferred to keep the sheet in the same format as the 3rd party product produces, so I was restricted to working with that and fell short with the know-how.

Thank you all,

Alex
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 39868534
Glad to help :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now