I have matrix report which dynamically generates my columns. Now one of the column has all integer data so I want to convert that to Integer type. Now I tried the below expression:
=IIF(IsNumeric(Fields!Answer.Value),CInt(Fields!Answer.Value),Fields!Answer.Value)
But this gave me error for some of the columns where some of the row data contains integer only while other rows contains mix. So I tried the below expression but still no luck!
=IIF(Fields!Question.Value = "Amount:", CInt(Fields!Answer.Value), Fields!Answer.Value)
So basically only the Amount:
column has true integer values, while all other columns have either all text or mix of text and integer data. So for all the columns with data as text and integer both, I get the error.
Sample Data:
+------+--------------+-----------+
|Name: |Phone Number: |Emp Number |
+------+--------------+-----------+
|Alice |123-456-7890 | 123 |
|Bob |2345678901 | 12345 |
+------+--------------+-----------+
In above sample data, Amount: contains all integer values whereas Name is all text and phone number is text and integer. Using the IIF(...) expression I get the below result.
Result:
+--------+--------------+-----------+
|Name: |Phone Number: |Emp Number |
+--------+--------------+-----------+
|#Error |#Error | 123 |
|#Error |2345678901 | 12345 |
+--------+--------------+-----------+
I looked at these references here and here for the solution but no luck. Any help on what I might be missing.
=IIF(Fields!Question.Value = "Amount:", "f0", "")
– Alan Schofield=IIF(Fields!Question.Value = "Amount:", FORMATNUMBER(Fields!Answer.Value, 0), Fields!Answer.Value)
– Hannover FistVAL
function instead ofCInt
. Just likeVAL(Fields!Answer.Value)
. Check chris's answer here for more details on why this works better in this case. – Steve-o169