In this webinar, our experts showcase a variety of demo use cases of how different components of the...
If you like or use FetchXML or math, you’ll like today’s post!
When creating a FetchXML SSRS report, applying mathematical calculations from the resulting textbox of an expression can sometimes be a quick way to retrieve values. For example, if you have multiple expressions and you are attempting to simply multiply or divide, instead of combining or in some instances recreating a huge new expression, you can use the actual textbox to perform these calculations instead!
Here are a few tips to calculate values:
1. Using the Report Items function will pull the value from an already calculated field and do the math without making additional expressions. Here is an example:
2. Report Items values can be Added, Subtracted, Multiplied, Divided, and more:
Remember to use parentheses to account for order of operations, as seen in the above screenshot.
3. When using Report Items to calculate values, there are some limitations:
This is a major limitation, but a way to work around this is to just make one large expression – typically pulling two datasets by using the =First function. Here’s an example:
=(CDec(Replace(First(Fields!field1.Value, "Dataset1"), "$", "")) +
CDec(Replace(First(Fields!field2.Value, "Dataset2"), "$", ""))
Adding the CDec function also assisted the values to be converted to a decimal – a frequent requirement with data, so it is recommended that you use it if you encounter an #Error. Also, adding the VAL function can assist with returning numbers as the appropriate type.
In conclusion, textbox field calculations can be a very powerful SSRS tool, allowing you to quickly perform opportunity cost/margin-type calculations on the fly. However, there are some serious limitations to account for. But, if you’re able to utilize them, textbox calculations are a great option!
Don't forget to subscribe to our blog. Happy Dynamics 365’ing!