- Microsoft Dynamics AX 2012 Reporting Cookbook
- Kamalakannan Elangovan
- 415字
- 2021-08-06 16:40:50
Expressions in layouts
Expression is an interesting capability that SSRS supports. They can be used not just in expressions but in every possible property that needs customization at run-time. This recipe will get us introduced to expressions, by implementing the most interesting feature of printing the alternate lines in different colors. We will use the layout template created in the previous recipe to implement this.
How to do it…
Expressions can be implemented in the report, as follows:
- On the template, select the node DetailRowStyle | FieldValueStyle.
- For the Background Color property, choose the Expression list:
- The expression window opens.
- Type the following expression in the expression window:
=iif(RowNumber(Nothing)mod 3, "#e0e0e0", "#ffe0c0")
- Save the template and go back to the
PktCustTransList
report for a preview. - The report should now appear with a different color on every third line when previewed.
How it works…
Expressions are powerful means through which you can manipulate the content and the formatting style of the report data. These are widely used across the report model to retrieve, calculate, display, group, sort, filter, parameterize, and format data. They are not just limited to the ones listed but apply to many properties. A precise definition would be that anywhere in the report if a drop-down list displays <Expression…> then expressions can be applied.
It creates a wide scope for manipulation, by providing access to the standard functions, data methods, fields, labels, and more. This can be compared to an Excel cell where a formula is evaluated to produce the data. Expressions are evaluated when the report is run, so the results can be seen through preview.
Here are a few sample expressions:

Expression syntax is based on Visual Basic and any syntax error is highlighted by a red color in the expression window. To know more about expressions, please refer http://msdn.microsoft.com/en-us/library/dd220516.aspx.
Tip
Many novice report designers tend to use the IIF()
function to test the parameter expression for a True
or False
result, and then explicitly return a True
or False
result from the function. Since all expressions can return Boolean results, although this technique will work, it's redundant to use the IIF()
function for this purpose. For example, the following expression could be used in place of the previous example:
=IIF(Parameters!ShowQuantity.Value = True, False, True)
The following example would be used to test the result of a non-Boolean value. By wrapping an expression containing a comparison operator in parentheses, we can cause the expression to return a Boolean result.
=(Parameters!ReportView.Label="Retail")
- Mastering Microsoft Forefront UAG 2010 Customization
- INSTANT Citrix XenDesktop 5 Starter
- 金融科技(FinTech)發展的國際經驗和中國政策取向(中國金融四十人論壇書系)
- 審計學基礎
- 審計綜合模擬實訓
- EViews10.0的應用與計量分析
- 項目管理(第二版)
- OAuth 2.0 Identity and Access Management Patterns
- 中國政府統計問題研究
- 從零開始學房地產會計
- IBM SPSS Modeler Cookbook
- 政策建模技術:CGE模型的理論與實現
- 財務會計習題集
- 汪博士解讀PMP?考試(第6版)
- 圖解經濟博弈論(圖解經濟學叢書)