Formatting Columns in SSRS Reports
When working on SSRS reports in the Dynamics AX 2012 reporting framework, a lot of the information comes over from the MorphX Extended Data Types. However, there are still times when you need to work in SSRS to make the format of the column match what your client requests.
For example, say you are calculating a percentage for your report, and your client wants to have the column display the value to one decimal place. Also, the requirement is to show 0.0 if the value comes in as 0. There really are a couple of ways to do this.
1. From what I have seen, the recommended approach is to use the Format property of the textbox that contains your value. Set the property to the following:
- This will put a comma between the hundreds and thousands column (if applicable to the value) and will default 0.0 into the column if the value is 0, otherwise the value will show up with a single decimal place.
2. Right click on the textbox, and choose Properties from the menu that appears. This allows you to control the formatting of the text that comes into the textbox based on the type of data (General, number, currency, etc.). Set the appropriate values based on the Development criteria for your data.
3. You can use an expression to do the work for you. The expression would be something like the following:
- This will do the same as the first example.
So, the question is, why bring this up? The reason I do so is, what happens if the client decides they want to have a percent sign ‘%’ be displayed after the value? If you use the formatting method where you set the format on the column, if you try to append a ‘%’ to the value, the report will show #Error in that column. BUT, if you use the second method, you can do an expression like the following (NO formatting property configuration on the text box):
=Format(Fields!Mypercentfield.Value,”###,##0.0”) + “ %”
This gives you additional flexibility in formatting the column, as you are not limiting what goes in the column by using the Format property of the textbox. I prefer to use the first method, but there are times where that just won’t work.