1

I have one integer data in my dataset column. I want to convert the integer value to string. For example: I have a column like class ID: 100, 200,300,...etc I need to change the "Class ID"data like 100 means it displays "Class A" 200 means it displays "Class B"

How can I do this convertion in Microsoft report bulider 2016

Yuvaraj A
  • 11
  • 1

1 Answers1

1

There are a few ways to do this. If you plan to use the same logic in more than one place then it would be a good idea to create a table in your database with a ClassID and ClassName so you can just join to this table in your query to return the ClassName.

If for some reason you cannot do this then you can do it with expressions in SSRS directly.

Your expression would look something like this.

=SWITCH (
         Fields!ClassID.Value = 100, "Class A",
         Fields!ClassID.Value = 200, "Class B",
         Fields!ClassID.Value = 300, "Class C",
         True, "Unknown Class"
        ) 

The final True acts like an else, so if none of the previous expressions match then '"Unknown Class"' would be returned.

Alan Schofield
  • 19,839
  • 3
  • 22
  • 35
  • Could also add the logic as a Calculated Field in the dataset. – Hannover Fist Oct 13 '22 at 23:46
  • tbh: That's probably a better option than this answer as it's more re-usable – Alan Schofield Oct 14 '22 at 09:14
  • Thank you Mr. Alan Schofield – Yuvaraj A Oct 16 '22 at 18:56
  • If this answer solved you issue, please mark it an answered ( the check mark to the left under to vote up/down buttons). This will helps others find answers to similar questions – Alan Schofield Oct 16 '22 at 22:02
  • Its working well Mr. Alan Schofied. But the same classID.value (TAG_ID.Value) column with integer & String values also. Now, I use like =SWITCH ( Fields!TAG_ID.Value = TIMER-21, "TIMER-21", Fields!TAG_ID.Value = TIMER-4, "200", Fields!TAG_ID.Value = TIMER-17, "TIMER-17", Fields!TAG_ID.Value = 1, "100", Fields!TAG_ID.Value = 2, "200", True, Fields!TAG_ID.Value ) – Yuvaraj A Nov 03 '22 at 17:09
  • you will need to enclose the values you are testing against in quotes e.g. `Fields!TAG_ID.Value = TIMER-4, "200"` should be `Fields!TAG_ID.Value = "TIMER-4", "200"` – Alan Schofield Nov 03 '22 at 17:10