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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Using match function in a loop

Raiko
16-Pearl

Using match function in a loop

Hello folks,

I ran into this problem of the match function. When used in a loop it claims to not have found a match. When used on its own it works just fine; see attached worksheet.

Does anybody know why? I'm using MC15 on a Win 7 machine.

Thanks in advance

Raiko

1 ACCEPTED SOLUTION

Accepted Solutions

Tghank you Mike for the hint. It led me to the solution. I simply had to trap the error when match didn't find a solution and now it's working like a charm.

Raiko

View solution in original post

16 REPLIES 16
MikeArmstrong
5-Regular Member
(To:Raiko)

Please upload the Excel data.

here we go Mike. It ought to work however with any Excel data.

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

Firstly are calling the wrong column of Q? Should you be calling column <2>?

I'm calling the second column of Q by invoking the matrix column command "Q<1>". That has worked so far.

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

The second column is Time - I assume you are not trying to compare the range month to time.

Something like the attached?

Clipboard02.jpg

Tghank you Mike for the hint. It led me to the solution. I simply had to trap the error when match didn't find a solution and now it's working like a charm.

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

RaikoRaiko Milanovic wrote:

Tghank you Mike for the hint. It led me to the solution. I simply had to trap the error when match didn't find a solution and now it's working like a charm.

Raiko

Super news. Could you please provide the solution to help others.

Both columns contain plain numbers. The second represents the months.

What I'm trying to do is to determine the averages of reliabilities per month. In this example only January and December are available, hence only the 1 and the 12 are present.

In other sheets I do have all months represented by numbers 1 through 12.

MikeArmstrong
5-Regular Member
(To:Raiko)

RaikoRaiko Milanovic wrote:

Both columns contain plain numbers. The second represents the months.

What I'm trying to do is to determine the averages of reliabilities per month. In this example only January and December are available, hence only the 1 and the 12 are present.

In other sheets I do have all months represented by numbers 1 through 12.

I'm sorry Raiko I am a little confused. In the data you provide column 3 contains values of 1 and 12, which coincide with the months of Jan and Dec, correct?

So which columns to you need to extract.

Please provide a simple example of the expected results.

I'm sorry Raiko I am a little confused. In the data you provide column 3 contains values of 1 and 12, which coincide with the months of Jan and Dec, correct?

Raiko's Excel files consists of two sheets. You are referring to the first one "Sheet1" but Raiko is accessing the second one "FVW" which consists of two columns only.

@Raiko: Are you looking for something like this:

1.png

MikeArmstrong
5-Regular Member
(To:Werner_E)

I didn't notice the second sheet. However, the second sheet is just reproducing the last two columns of sheet 1.

Mike Armstrong wrote:

I didn't notice the second sheet. However, the second sheet is just reproducing the last two columns of sheet 1.

Yes, but it would not be necessary to use Excel itself to get the month number or make a copy of the data.

Using an appropriate Mathcad routine which converts an Excel date number to a date we could use the "raw data" itself:

1.png

MikeArmstrong
5-Regular Member
(To:Werner_E)

Nicely done.

Hello Mike,

no need to worry any longer. I found a workaround to trap the error.

Sorry for the Excel sheet, I forgot to mention that I'm accessing only sheet 2.

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

No problem, glad you got the solution.

Top Tags