Ian
Ian

Reputation: 53

SSRS Dynamic String Expression

I am creating a report where I need to indent a row in a table based on a value from my result set for that row. For example if the value is 0 don't indent at all. If the value is 1 indent by 5 spaces. If 2 indent by a factor 10 spaces, etc.

The way I originally tried to do this is to use something like this:

= Space(Fields!depth.Value * 5) + Fields!name.Value

This works fine when rendered in visual studio but displaying it in the browser window when rendered through reporting services causes those spaces to be removed. I got around this problem before with this tip: http://mssqltips.com/tip.asp?tip=1286.

Any suggestions on how to dynamically control this indentation? I want to be able to do this dynamically with out hard coding numerous IF statements as im trying to make this report flexible enough that I can get any number back for this value.

Upvotes: 5

Views: 5239

Answers (1)

Matt Hamilton
Matt Hamilton

Reputation: 204129

You could try setting the left padding on the cell in question to an expression like this:

=CStr(2 * Fields!depth.Value) + "pt"

You might have to play with the multiplier since it's points rather than spaces.

Upvotes: 4

Related Questions