Help find DataStage function !!
Moderators: chulett, rschirm, roy
Help find DataStage function !!
Hello All,
I want to find the word "Reversal" from one of the column in the transformer stage from the string.
Example Column A has 100 rows, first 5 are
Client Reversal,
REVERSAL Coding W/O
Contractual Allowanced
Diversified Payment Reversal &
Patient Payment
I want to add a logic in column B which is amount field (decimal datatype).
The logic is if I find the word "Reversal" or "reversal" or "REVERSAL" in column A, I want to change Column B to negative (-) amount else leave it as positive.
Is there a function that would help me find specific word in the string?
Please help.
Thank You,
-Sam
I want to find the word "Reversal" from one of the column in the transformer stage from the string.
Example Column A has 100 rows, first 5 are
Client Reversal,
REVERSAL Coding W/O
Contractual Allowanced
Diversified Payment Reversal &
Patient Payment
I want to add a logic in column B which is amount field (decimal datatype).
The logic is if I find the word "Reversal" or "reversal" or "REVERSAL" in column A, I want to change Column B to negative (-) amount else leave it as positive.
Is there a function that would help me find specific word in the string?
Please help.
Thank You,
-Sam
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
You can use the following logic in your transformer to get the desired result
If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB = INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Try it and let me know if it works for ya.
If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB = INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Try it and let me know if it works for ya.
Last edited by pnchowdary on Thu Jul 07, 2005 2:29 pm, edited 3 times in total.
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
There was a small error in the logic i mentioned above, Please use the below logic in your transformer
Code: Select all
If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Chowdary,
Thanks for the input.
Could you please check the below syntax. Sorry for asking lame questions but I am new to DataStage. I want to check for NULL values.
So, I want to add the below logic only if COLA is NOT NULL. How do I do it? Below logic is erroring for me.
If IsNull(INPUTLINK.COLA) = 0 AND If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Thanks!!
Thanks for the input.
Could you please check the below syntax. Sorry for asking lame questions but I am new to DataStage. I want to check for NULL values.
So, I want to add the below logic only if COLA is NOT NULL. How do I do it? Below logic is erroring for me.
If IsNull(INPUTLINK.COLA) = 0 AND If (Count(UPCASE(INPUTLINK.COLA),"REVERSAL")) > 0 Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Thanks!!
Looks like I might have got it...Please confirm...
Also could you please tell me if its going to find all reversals in the string; REVERSAL, Reversal, & reversal in the UPCASE(count) function below...
Thanks !!
If (IsNull(INPUTLINK.COLA) = 0 AND Count(UPCASE(INPUTLINK.COLA),"REVERSAL") > 0) Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Also could you please tell me if its going to find all reversals in the string; REVERSAL, Reversal, & reversal in the UPCASE(count) function below...
Thanks !!
If (IsNull(INPUTLINK.COLA) = 0 AND Count(UPCASE(INPUTLINK.COLA),"REVERSAL") > 0) Then (INPUTLINK.COLB * -1) Else INPUTLINK.COLB
Me48, a couple of points:
You don't need to check the results of an IsNull() call against 0 or 1, even though that will work. Being a boolean, it is easier to read if you just say
If IsNull(INPUTLINK.COLA) to see if COLA is a null -or-
If Not(IsNull(INPUTLINK.COLA)) to see if COLA is not null
You don't need the not null check in your expression, it doesn't really add any value as a null string won't trigger any false positives in your Count check. You should be fine with pnchowdary's original version... and yes, because you upcase the field and check against 'REVERSAL' it will work not matter what the case in the original string.
You don't need to check the results of an IsNull() call against 0 or 1, even though that will work. Being a boolean, it is easier to read if you just say
If IsNull(INPUTLINK.COLA) to see if COLA is a null -or-
If Not(IsNull(INPUTLINK.COLA)) to see if COLA is not null
You don't need the not null check in your expression, it doesn't really add any value as a null string won't trigger any false positives in your Count check. You should be fine with pnchowdary's original version... and yes, because you upcase the field and check against 'REVERSAL' it will work not matter what the case in the original string.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA