cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Filter data using comboboxes

SN_8612563
4-Participant

Filter data using comboboxes

Hi!

Is there a way to make a filter based on comboboxes ? i.e.

 

I want to be able to filter "Type" and "Version" so that the end result is a matrix i can plot

 

I used vlookup to easily filter "Type", but not sure how i can incoorporate the "Version" filter?

 

(I've attached my sheet, MCP 9)

 

Thank you!

 

2023-06-21_12-17-05.png

 

Regards
SNA

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

It looks to me that you are looking for a n x2 matrix as the result of the filtering!?

You may write a filter function like the one shown below

Werner_E_2-1687344850178.png

Werner_E_1-1687344475316.png

BTW, you had a typo in the version "A" in the first data row, there was an extra "

 

View solution in original post

4 REPLIES 4

It looks to me that you are looking for a n x2 matrix as the result of the filtering!?

You may write a filter function like the one shown below

Werner_E_2-1687344850178.png

Werner_E_1-1687344475316.png

BTW, you had a typo in the version "A" in the first data row, there was an extra "

 

Here is a different approach, a tricky one-liner

Werner_E_0-1687348285980.png

You may use try  & catch for some error trapping

Werner_E_1-1687348320398.png

 

 

SN_8612563
4-Participant
(To:Werner_E)

Hi @Werner_E 

 

Thank you so much!

 

Your first suggestion worked perfectly on a bigger data set i have 😁 Although i must confess i do not quite understand what is happening here: 

 

2023-06-21_13-57-45.png

I will also try your one-liner 🙂

 

Regards
SNA

 

Yes, this approach is tricky and its "necessary" because Prime and Mathcad do not offer a structure like an empty array.

What the loop does is to collect all entries which fulfil both conditions.

Normally you would stack the new entry at the bottom of the ones already present via Res <-- stack(Res, [... ...]).

But the problem here is the first entry. On way around it would be to define a dummy row of Res in front of the loop (maybe column headers) and at the end you can decide if you want this headers be present or you cut them off using the submatrix function. If the array is only used for plotting, you may use a first row of NaN's.

Werner_E_0-1687357804896.png

 

Here is a yet another way to create the desired matrix (without a header row). A counter variable is used to assign the rows.

Werner_E_1-1687357937838.png

You can save one line if you do the increment of the counter right in the row selector

Werner_E_2-1687358017848.png

 

Now for the explanation of my first suggestion. It benefits from the fact that the row( ) function returns a zero if its argument is a scalar or a string. And the method also uses the ORIGIN=0 setting and so the first time row(Res) returns 0 and so the first found values are inserted as row #0. Now the number of rows in Res is 1 and so the next entry is inserted as row #1 which means its the second row.
The function as I posted it assumes that you did not change the value of ORIGIN, but you can easily make it ORIGIN aware so it can be used in any sheet, no matter what its ORIGIN setting is.

Werner_E_3-1687358094028.png

Normally I would assign   O <-- ORIGIN as the first line of the program and use O instead of ORIGIN

 

Top Tags