Link to home
Create AccountLog in
Avatar of rhservan
rhservanFlag for United States of America

asked on

Can I write this in an expression or is there a better way in custom code?

Let me know if you need additional clarity to my question!

Current: This works as needed.

=Right(Fields!REASONB.Value,Len(Fields!REASONB.Value) - InStrRev(Fields!REASONB.Value,"-"))

This expression removes all characters from first instance of  '-', located from the right end of string, to the beginning of the string.

Example:

When expression runs on data below

ReasonB
SMPLT - QSY - Error 1234

Returns

ReasonB
Error 1234
----------------------------------------------------------------------------------------------------------------------------
Desired:

In addition to the above expression I would like to COMPARE Fields!REASONB.Value with Fields!REASONA.Value

For an example:

If Fields!REASONB = Fields!REASONA Make ReasonB column blank.

ReasonA                                                 ReasonB
SMPLT - QSY - Error 1234                               SMPLT - QSY - Error 1234

Returns

ReasonA                                                 ReasonB
SMPLT - QSY - Error 1234                              

OR

If Fields!REASONB <> Fields!REASONA Return Maintain what is already in Fields!REASONB

ReasonA                                                 ReasonB
SMPLT - QSY - Error 1234                               Flooding

Returns

ReasonA                                                 ReasonB
SMPLT - QSY - Error 1234                               Flooding
Avatar of ChloesDad
ChloesDad
Flag of United Kingdom of Great Britain and Northern Ireland image

Do you want the A and B check to be done before the modification of B or after?
Avatar of rhservan

ASKER

I would want to remove the duplicates as explained in the desired first.

Then the string segement removal as in current second.
ASKER CERTIFIED SOLUTION
Avatar of ValentinoV
ValentinoV
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
It seems the expression above is only returning the Else portion of the IIF.

Example:

ReasonA                                                 ReasonB
SMPLT - QSY - Error 1234                     SMPLT - QSY - Error 1234 <-------duplicate to ReasonA (=)

Returns

ReasonA                                                 ReasonB
SMPLT - QSY - Error 1234                     Error 1234   <-------- Should be nothing
I found an issue with ReasonB. There is a trailing space on some of the comparisons which causes the problem with ReasonA = ReasonB due to the additional space.

I will correct this and let you know.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.