Convert a Crystal Report formula
In Crystal, I can create an If/then statement in a formula. For example: if{Product.Product_Line} like ["05A11*","05A12*","05A13*","05A31*","05A32*","05A33*"] THEN "KITCHEN" ELSE if{Product.Product_Line} like ["05A21*","05A22*","05A23*"] THEN "LINENS" ELSE if{Product.Product_Line} like ["05B11*","05B12*","05B13*","05B31*","05B32*","05B33*","05C11*","05C12*","05C13*","05C31*","05C32*","05C33*"] THEN "MENS CLOTHING" ELSE if{Product.Product_Line} like ["05B21*","05B22*","05B23*","05C21*","05C22*","05C23*"] THEN "BOYS CLOTHING" ELSE "UNKNOWN PRODUCT" Now, I know I can use the Switch in SSRS, to list every line one by one, but is there a way I can still group similars together just like Crystal? In other words, is there a way to still use: ["05A21*","05A22*","05A23*"] THEN "LINENS" So everything enclosed in [] can be called "LINENS" Thus, I have one line of code in this case instead of three. I have hundreds in some categories, so I would like to find a way to cut down the number of lines so it's more manageable. Thx
September 29th, 2011 11:51am

Hi newbie2244, In Reporting Services, there is still no need to list every line one by one, actually, you can use Instr and Switch function conjunctively, such like this: =SWITCH(Instr("05A1105A1205A1305A3105A3205A33",Fields!Product_Line.Value)>0, "KITCHEN", Instr("05A2105A2205A23",Fields!Product_Line.Value)>0, "LINENS", Instr(05B1105B1205B1305B3105B3205B3305C1105C1205C1305C3105C3205C33",Fields!Product_Line.Value)>0, "MENS CLOTHING",Instr("05B2105B2205B2305C2105C2205C23",Fields!Product_Line.Value)>0, "BOYS CLOTHING", Instr("05A1105A1205A1305A3105A3205A3305A2105A2205A2305B1105B1205B1305B3105B3205B3305C1105C1205C1305C3105C3205C3305B2105B2205B2305C2105C2205C23",Fields!Product_Line.Value)=0, "UNKNOWN PRODUCT") Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 5:12am

Challen, Thanks for trying, but there's an error. I don't think it likes the wildcard. I'll keep the code short so it's easier to follow for the Instr("05A11*","05A12*"), it just shows up blank. If I put the following: Instr("05A11R","05A12R"), it does work. How can I get the R as a wildcard? I've tried several thoughts and bombed out.
October 13th, 2011 5:36pm

Hi I have a question about a short formula: IF {ado.UOM}="LB" THEN crNoColor ELSE IF {ado.UOM}="KG" THEN "{ado.Pieces}x{ado.Size1}" When I check this formula,there is an error. it always shows that there is some number required. Thank you for help
Free Windows Admin Tool Kit Click here and download it now
August 20th, 2012 12:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics