How to use AND logic with STRiff function

Discussion forum about all things Report Builder (all versions).
SkuzeeII

How to use AND logic with STRiff function

Post by SkuzeeII » 15 Sep 2016, 19:47

I want to setup a formula that checks two strings to see if they match two different values & return something if they match or not. How can I do that?

Zephy

Re: How to use AND logic with STRiff function

Post by Zephy » 19 Sep 2016, 12:37

You can use StrScan function with StrIFF.

Code: Select all

StrlFF(StrScan('first_string', 'second_string'),'are_different','are_equal','are_different')

SkuzeeII

Re: How to use AND logic with STRiff function

Post by SkuzeeII » 23 Sep 2016, 16:34

I need to do that for two separate StrIFF functions.
If String1 = XXX AND string2 = YYY then XYZ

SkuzeeII

Re: How to use AND logic with STRiff function

Post by SkuzeeII » 27 Sep 2016, 20:45

I figured out a way to do it by adding together StrCompare functions and wrapping their sum into a StrIFF Just in case anyone else runs into this.

Code: Select all

StrIFF( StrCompare('x', 'x') + StrCompare(StrLeft('y', 'y') , '' , 'PRINT' , '' )

User avatar
Charlie
Canada
Posts: 652
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: How to use AND logic with STRiff function

Post by Charlie » 28 Sep 2016, 11:18

Good stuff !

TerryP
Australia
Posts: 273
Joined: 06 Mar 2017, 22:41
Location: Mackay QLD Australia

Re: How to use AND logic with STRiff function

Post by TerryP » 28 Sep 2016, 23:50

Be careful when adding the results of two StrCompare( ) calls together, if the first one returns -1 (less than) and the second returns +1 (greater), then the sum will be zero, which will select the central option ('PRINT') in the StrIFF( ) function.

To get around this, use the NumberAbsolute( ) function around each of the StrCompare( ) calls to ensure the two results don't cancel each other out!

Cheers,
Terry Phythian
Reprise Consulting

User avatar
Charlie
Canada
Posts: 652
Joined: 07 Mar 2017, 18:52
Location: Fredericton, New Brunswick, Canada

Re: How to use AND logic with STRiff function

Post by Charlie » 29 Sep 2016, 11:30

TerryP: +1 !

Return to “General Discussion Report Builder”

Who is online

Users browsing this forum: [Ccbot] and 0 guests