Different data types in the same field
Hi, I need to display different values in the same tablix column, and each of these values could be string, currency, date, etc. depending on the source data. My query does give me both the value and another field with the type (e.g. Value = 10,000, Type = Decimal). With this data should it be possible for me to do something like this in the field expression: =iif(Fields!Type.Value="xs:string",Format(Fields!Value.Value),iif(Fields!Type.Value="xs:decimal",FormatCurrency(Fields!Value.Value),Fields!Value.Value)) The reason I ask is that I have tried this and my where I have string fields that are not numeric, the value is shown as 'error'. Many thanks
August 29th, 2012 12:06pm

Well, If it is xs:string, why do you have it as "Format(Fields!Value.Value)" What Format Type are you selecting? I don't see any. Others are specifying a Target Format, but not for xs:string Remove the Format ( ) wrapper for the xs:string and simply present the data as "Fields!Value.Value"Todd C - MSCTS SQL Server 2005, MCITP BI Dev 2008 Please mark posts as answered where appropriate.
Free Windows Admin Tool Kit Click here and download it now
August 29th, 2012 2:12pm

In addition to Todd's suggestion, you probably need to check the datatype of the Type field. You could try something like this: =iif(IsNumeric(Fields!Type.Value),Format(Fields!Value.Value,"C2"),Fields!Value.Value) btw, C2 will give you something like $123.45. No floating points, use C0. good luck.Think out of the box
August 29th, 2012 3:45pm

I'm just giving a couple of examples to illustrate what I have to work with - a type field and a value. I could have used xs:dateTime instead of xs:string, or xs:int, etc.. By the way, If I do remove the format in that particular example the result is exactly the same - the non-numeric fields display as error.
Free Windows Admin Tool Kit Click here and download it now
August 30th, 2012 4:24am

Hi, thanks for the response. The 'Type' field is just a string representing the datatype, so I can't check to see if that's numeric or not. I could check the value field instead I guess, but the values in the dataset are all varchars initially, that's why I want to use the associated type field to convert them for display purposes. And if I can do this then I would want to display a 0 that's an int as 0, but a 0.00 that's a decimal as $0.00. Does my expression look like it should be feasible and there's just something obvious that I'm missing or is what I'm trying to do a complete no-go?
August 30th, 2012 4:35am

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

Other recent topics Other recent topics