Skip 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.

Filtering values of variables

Featured Replies

I am trying to filter two variables but I can't make it work.

 

Could someone point me what am I doing wrong?

 

Thank you.

Sample.zip

You are incorrectly understanding the result of the filter operation.

The result is a list.

But your script step is looking for a true/false value.

 

Filter( "Black¶White¶Red¶Blue¶Green"; "Black") results in "Black"

 

You want to test for the value count of the result.

 

 

Set Variable [ $Colors; Value:"Black¶White¶Red¶Blue¶Green" ]

Set Variable [ $FilterColor; Value:"Black" ]
Set Variable [ $result; Value:FilterValues ( $Colors ; $FilterColor ) ]

If [ ValueCount( $result ) ]

Show Custom Dialog [ Title: "It filters"; Default Button: “Aceptar”, Commit: “Yes” ]

Else

Show Custom Dialog [ Title: "It doesn't filter"; Default Button: “Aceptar”, Commit: “Yes” ]

End If 

Also, if you did:

 

Set Variable $FilterColors ; Value:"Black¶Purple" ]

Set Variable [ $result; Filter( "Black¶White¶Red¶Blue¶Green"; $filterColors)]

 

The result would be "Black"

 

You would probably want to test for valueCount( $result ) = valueCount( $filtercolors )

  • Author

I’m sorry but I think I didn’t explain myself well.

 

My goal:

 

I’m working on a Show Custom Dialog TAG.

 

I want to use the $AvailableColous variable as the TAG of a field. Once a colour is chosen, the next time I go through the dialog (I know a loop is needed), the TAG shouldn’t show the already chosen colour.

 

What I try to accomplish is to dynamically exclude the chosen colour from the available ones.

 

In another one of my posts, EOS, suggested me to use filtered portals instead of value lists. He drove my sample in that direction and in one of his sample scripts filters two variables to later exclude value in the filtered.

 

http://fmforums.com/forum/topic/89458-conditional-vl-including-2-join-tables/

 

script: SelectExecsInHolding,

section: #keep both lists synchronous

 

That is what I’m trying to do but I still can’t manage it. Too many to learn yet.

 

Thank you.

 

I’ve made some changes to the sample file.

Sample.zip

Well, perhaps you made some changes but they can't work because you ignored the logic problem of your IF statement.

 

Your statement

 

If [ FilterValues ( $AvailableColours ; $ChosenColour ) ]

 

Does not work as written.

 

It needs to be:

 

 

If [ ValueCount( FilterValues ( $AvailableColours ; $ChosenColour )) ]

SampleMOD.fmp12.zip

If [ ValueCount( FilterValues ( $AvailableColours ; $ChosenColour )) ]

 

This usually isn't a substantial difference, but the calculation will usually evaluate a little faster like so:

 

If [not IsEmpty ( FilterValues ( $shorterList ; $longerList ) )]

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.