OR in StrIFF

SqlBase and Centura Solutions
ldoodle

OR in StrIFF

Post by ldoodle » 22 May 2018, 10:53

Hello,

I am totally new to QRPs but our finance app uses them to generate invoices. We have a requirement where we want to output a string based on the value of something taken from the app.

From what I can gather, StrIFF returns 3 values: -1 if the input value is lower than the comparitor, the input value if it equals the comparitor, and the value higher than the input value.
Take this as the input value: AUD

Code: Select all

StrIFF(StrCompare(inputvalue, 'GBP'), '1', '2', '3')
In this case the result will be 1, because AUD is alphabetically before GBP. IF the inputvalue was USD, the result would be 3.

What I need to achieve is:
if the inputvalue is either AUD, NZD output 'W', if it's GBP, EUR output 'X', if it's HKD, JPY output 'Y', if it's CAD output 'Z' and so on and so on.

How do I achieve this?

Thanks so much!

User avatar
Steve Leighton
Site Admin
Site Admin
New Zealand
Posts: 463
Joined: 05 Mar 2017, 20:57
Location: Stroud, England <--> Tauranga, New Zealand

Re: OR in StrIFF

Post by Steve Leighton » 25 May 2018, 06:55

Greetings from NZ !
And welcome to Gupta ReportBuilder. Hang in there it does get easier.

Try:
StrTranslate(inputvalue, 'AUD,NZD,GBP,EUR,HKD, ....','W, W, X, X, Y, ....')

Syntax

StrTranslate(inputvalue,csv1,csv2)

Finds the value specified by inputvalue in csv1. The function takes the position of the item in csv1 and finds and returns the item in csv2 that is in the same position.

Parameters

inputvalue: The comparison variable. Must be a string data type.

csv1: A string composed of comma delimited look-up values. The contents of type are compared to this list. For example, 'N,S,W,E'.

csv2: A string composed of comma delimited values, one of which is returned by the function. For example, 'North, South, West, East'.

Example

StrTranslate (region, 'N,S,W,E', 'North, South, West, East')

In this example, region is an input item with a data type of string. The StrTranslate function returns one of the following depending on the value of inputvalue.

inputvalue substring returned

Code: Select all

N North
S South 
W West
E East
Greetings from New Zealand
Steve Leighton

Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand

www.banksidesystems.co.uk

Image

User avatar
Steve Leighton
Site Admin
Site Admin
New Zealand
Posts: 463
Joined: 05 Mar 2017, 20:57
Location: Stroud, England <--> Tauranga, New Zealand

Re: OR in StrIFF

Post by Steve Leighton » 26 May 2018, 05:20

Greetings from New Zealand
Steve Leighton

Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand

www.banksidesystems.co.uk

Image

Return to “TekTips”

Who is online

Users browsing this forum: [Ccbot] and 0 guests