SSRS 2008 - dynamic format of textbox
Hi, I'm just trying to dynamically format the textbox number based on the grouped column header. So I've right clicked on the data cell and then Text Box Properties -> Number -> Custom -> Expression editor and added this: =iif(Instr(Fields!ComponentName.Value, "%") > 0, "#,0.00;- #,0.00", "") ie. if there is a % sign in the header, round it to 2 decimal places or do nothing if no % sign is in the column header text. Pretty simple eh? But it doesn't work... anything I put in here get's ignored... so how do you make formatting dynamic like this? Thanks, Andrew.
June 28th, 2011 4:06am

Hi Andrew, Can you check with this expression? to narrow down the issue:- = IIf ( Instr ( Fields!ComponentName.Value, "%") > 0, "Yes", "No") Please let us know your feedback. Thanks KumarKG, MCTS
Free Windows Admin Tool Kit Click here and download it now
June 28th, 2011 4:24am

Thanks for the reply Kumar, I tried your Yes/No test but it doesn't really do anything for numeric formatting... so I tried just putting 0.00 for both the true and false parts of the iif and it still fails to do any formatting at all! I think it's to do with the fact it's got string variables in the data, so ssrs may not be able to apply any formatting at all with this scenario. I've solved it by resorting to a code function and it looks like it's working! :) Public Function FormatValue( ComponentName as string, Prediction as String) Try if Instr(ComponentName, "%") > 0 Return Round(CDbl(Prediction), 2) else Return Prediction end if Catch Return Prediction End Try End Function
June 28th, 2011 6:58am

I think Kumar was trying to resolve the actual expression he gave, to make sure it gives the results you expect (but not using it as a numeric formatting expression, just a display expression for testing to make sure the expression itself was being evaluated correctly) I suspect your data is coming back as a string (given that it can include a percentage sign) and that might be why its having trouble formatting it for you as a number.
Free Windows Admin Tool Kit Click here and download it now
June 28th, 2011 7:35am

Hi Andrew, As ClareMorre I was trying to narrow down the problem. Anyways looks like you have fixed the issue yourself that great. Please complete this thread as Marked otherwise let us know if you have any more doubts. Thanks KumarKG, MCTS
June 28th, 2011 10:10am

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

Other recent topics Other recent topics