Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 20764

SSRS Expressions: how to check if a VarChar is in deed a decimal, BEFORE converting

$
0
0

I can't seem to get this expression to work correctly, it returns the following error: Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘txtMain.Paragraphs[0].TextRuns[0]’ contains an error: Input string was not in a correct format. 

The rows with 0) Order values are "Errored" out; but all subsiquent rows are returned correctly. 

=IIF((Fields!SortGroup.Value="0) Order")
,(Fields!Description.Value + " " + Fields!Answer.Value + " " + Fields!Answer2.Value + " " + Fields!Answer3.Value)
,("      " + Fields!Question.Value + ": " + IIF(IsNumeric(Fields!Answer.Value), CInt(Fields!Answer.Value).ToString, Fields!Answer.Value)  + " " + Fields!Answer2.Value + " " + Fields!Answer3.Value))

The intent, is if the SortGroup column = "0) Order" then

Description +Answer + Answer2 + Answer3

ELSE

Question + (Convert answer 1 if numeric to decimal, else print varchar) + answer 2 + answer 3

Answer column is a CAST(VarChar) from SQL with both numbers and characters in the field;

I have tried all the combinations of IsNumeric I can think of and cannot get the desired results.  If I remove the IIF statement from the 2nd half of the expression all works perfectly, except my VarChar numbers have trainling zeros after the decimal

Thanks


SQL Padre
http://sqlpadre.wordpress.com


Viewing all articles
Browse latest Browse all 20764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>