How to Change data type in expression

  • Hi

    All,

    i Would like to write the expression inside the matrix reportitems to evaluate if it sees Offered of Metric field then store Value as int else as char? something like this but it didnot work, can anybody help?

    =iif(Fields!Metric.Value="Offered",Cint(Fields!Value.Value),cchar(Fields!Value.Value))

    Metric Value Date

    Offered 10986 Jul - Week 1

    Abandon %1% Jul - Week 1

  • If I understand this correctly, under one condition you want an integer, and under another condition you want a string? This can't be done. However, you can convert the integer to a string using CSTR().

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Is it real this can't be done? If this is true what is the reason behind this?

    Thanks for the prompt response

  • simon phoenix-479217 (8/31/2010)


    Is it real this can't be done? If this is true what is the reason behind this?

    Thanks for the prompt response

    It's pretty much impossible to have one field be multiple data types. Anything that is strongly typed would have an issue with this.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Thanks for the response!

    Do you know any work around on this, lets say i want it like this format;

    Inside SSRS Report Item matrix(Desired Format). I need Offered as int data type to get the format of thousand separator but rest of them as varchar to accept the data format as it is, that is the whole reason for all this drama

    Sunday Monday

    Offered 1,020 1,022

    AHT 00:00:30 00:45:34

    Abandon 30% 26%

    source table format

    Metric Value Day

    Offered 1020 Sunday

    Offered 1022 Monday

    AHT 00:00:30 Sunday

    AHT 00:45:34 Monday

    Abandon 30% Sunday

    Abandon 26% Monday

  • SSRS textboxes are not really typed. However your formula indicates fields!value.value for both values, but you are trying to cast them differently. Are you saying you are getting an int and a char result from the same column on the source? Did you try the CSTR as suggested above?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply