I need some assistance on writing an expression that can display different account numbers depending on a starting value of another cell.
For example, right now I have it setup like this,
=iif(Fields!ShipViaCode.Value Like"F*", “XXXXXXXX”,“YYYYYY”)
This will show our Fedex account #, when the ship via starts with a F, and for any other via it shows our UPS account number.
This would work great if all we had was UPS and FedEx, but we also have DHL that needs to be shown. Is there any way to write it so it can see if the ship via starts with an U, F, or a D and then insert the correct corresponding account number?
This may not be the BEST solution, but you could do something like:
=iif(LEFT(Fields!ShipViaCode.Value,1) = “F”, “FedEx”,iif(LEFT(Fields!ShipViaCode.Value,1) = “U”, “UPS”,“DHL”))
The LEFT function will just start at the left of the string and then count the number of characters specified.
@Ross.Fireball.Kuiper I was thinking similar.
GOLD this is GOLD!
I actually added to the end to take it the one step further and display the DHL number, but if it doesn’t start with a D, then to leave it blank. Once I see how you start the composition I can usually add to it, I just don’t know the language well enough to start talking to it… LOL
I think it’s ‘SWITCH’ in what you are looking for. A little more streamlined. But for the limited example, the nested iif works well.
Fields!ShipViaCode.Value Like "U*", “UPS#”,
Fields!ShipViaCode.Value Like "F*", “FEDX#”,
Fields!ShipViaCode.Value Like "D*", “DHL#”,
True, "PleaseAddCarrier#" )