Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Counting repetitions on a field

Featured Replies

Hello, i have an interesting issue here that would like to share with you guys and hopefully solve it since its very important for a process which i am working in my company.

The process is based on a scan of products in a global fields formatted as text. The scan may contain numbers from 2 digits until 6 for example:

12

123

1234

12345

123456

After the scan is done i do a process which looks for the related parts in our inventory which thats already working good, after that it goes to the first part and checks on the global scanned how many times that part has been scanned, this is where the problem comes.

Lets say i scanned 35 parts with the part number 2222, i use the patterncount function to count how many repetitions of this number is in the field, the result should be 35 but if there is another part that has a number 12222 will count is as 36 when only 35 of the parts are the same.

Is there any way to count only the exact string?

I prepared this example so you can see it, i hope you guys can help me on this issue, i will be more than appreciated.

test.zip

Try

PatternCount( ¶ & test::g_text & ¶ ; ¶ & test::int & ¶ )

  • Author

unfortunally it doesn't work, i have tried with the part 5639 which has 35 parts and the result returned 19, i have formatted the function like this:

PatternCount( "¶" & test::g_text & "¶" , "¶" & test::int & "¶" )

Ah oops. Should have thought it out more.

Here

PatternCount( test::g_text & "¶" ; test::int & "¶" )

AFAICT, the global field in the above file contains 36 values of "5639", not 35.

PatternCount( test::g_text & "¶" ; test::int & "¶" )




returns 37, because it includes "15639" in the count.





Try:




PatternCount( "¶" & Substitute( g_text , "¶", "¶¶" ) & "¶" , "¶" & int & "¶" )

See the help on PatternCount() why this needs to be so.

Note that the relationship is not required for this.

  • Author

Comment:

YOU ARE THE MAN, i mean, i don't understand the theory you used that much, it's kind of catchy but it does the job it has to do, im really impressed, a million thanks, i'll keep checking this out to see how it really works.

Again, thanks a bunch!!!

Michael has corrected it once again. I was correct in the orginal path I was heading down with both Pilcrows. The thing was that I had forgotten that PatternCount was not inclusive.

So when you have

[color:red]

5639

5639

It only counts it once and returns 1.

So Michael used a subsitute to change all the single returns into double returns. Once that is done, the PatternCount will work.

[color:red]

5639

¶[color:green]

5639

This counts twice and returns 2.

  • Author

Ohh i see, because if you don't include double return the patternCount would take the return of the next string and there would a return missing for the next repetition so it skips one repetition and goes to the next one.

Very well, i guess i learned something new very interesting today.

Thanks for the support guys!

Edited by Guest

As always, I learn something new from you every day. :

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.