Expression Editor for multiple possibilities

4 posts, 0 answers
  1. James
    James avatar
    12 posts
    Member since:
    Mar 2019

    Posted 09 Apr Link to this post

    How can I use the expression editor or some other means to assign a string to a numeric value.  For example, I have status integer values that would show up in the legend of my chart but I want the proper string for those values.  There are about 12 different status values with associated strings.  How can I make this happen?  I don't have a database table with the string values to join.

    Thanks

  2. James
    James avatar
    12 posts
    Member since:
    Mar 2019

    Posted 09 Apr in reply to James Link to this post

    I am new to Telerik reporting and I want to make sure I asked this question correctly.  I am reporting on data that has an integer id stored in the database and I am creating a pie chart to show percentages of each type by id number.  What I want to do is provide a string to display in the legend instead of the integer value.  Please see attachment.  How could I do this without having the strings being a part of the data from the query?  Is there a way?  Thanks
  3. James
    James avatar
    12 posts
    Member since:
    Mar 2019

    Posted 09 Apr Link to this post

    sorry, forgot the file
  4. Neli
    Admin
    Neli avatar
    172 posts

    Posted 12 Apr Link to this post

    Hi James,

    If I understood correctly, you would like to set specific strings for each ID (numeric value) in the graph legend which are not taken from the data source. If so, there are two options:

    1) If you have known limited number of values (e.g. 3), you can use nested IIf Statements for the Value of the Legend Item. This can happen in the following way:

    Click on the barSeries -> Misc -> expand LegendItem-> Value set with an Expression like :

    = IIF(Fields.Id = 1, "First ID", IIF(Fields.Id = 2, "Second ID", "Third ID"))

    Note that you may nest more IIFs (to substitute "Third ID"). Please, check the attached screenshot and report which demonstrate this solution.

    2) The second option is by using UserFunction, in case you have a lot or unknown number of values. You may pass the Id as parameter of the User function and return a string based on the passed Id.

    Please, let me know if you have any additional questions.

    Regards,
    Neli
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top