- IBM Cognos 8 Report Studio Cookbook
- Abhishek Sanghani
- 472字
- 2021-08-06 17:15:48
Running difference: Negative values in brackets and red
Business owners need to see the sales figures by months and their month-on-month difference.
If the difference is negative (fall in sales) then it needs to be shown in red and values need to be in brackets.
Getting ready
Create a simple list report with Time Dimension | Current year, Time Dimension | Current month, and Sales fact | Quantity as columns.
Group Current year and sort Current month ascending.
How to do it...
- Add a new query calculation to the list. Define the expression as:
running-difference([Quantity])
Call this item as "Running Difference".
- Open the Data Format properties for this calculation from Property list.
- Set the Format type as Number and the Negative Sign Symbol as brackets ().
- Now go to Condition Explorer and create a new condition variable of Boolean type. Define the condition as:
[Query1].[Running Difference] < 0
- Call the variable as
Show_Red
. - Now go back to report page and select the Running Difference column. Assign
Show_Red
variable as Style Variable from the property list. - Choose the Yes condition for
Show_Red
from the conditional explorer. Select 'Running Difference' column from the list and open its Font properties. - Set the font foreground color to red.
- Click the OK button. Double click on the green bar to come out of condition. Run the report to test.
How it works...
One purpose of this recipe is to introduce you to powerful aggregation functions provided by Cognos. The Running difference function returns difference between value in current row and previous row. You can also control the scope and level of aggregation.
In this example, we leave the scope and level of aggregation to default.
There are other such functions provided in Report Studio (for example, Running-maximum, Running-Count, Running-Total, and so on) which are useful in real life scenarios.
MS Excel has traditionally been the most popular and widely-used tool for information access. It is easy to use and gives enough power for the business users to do their analysis. It readily allows you to display negative numbers in red and brackets, which is a popular choice in the finance world.
However, under the Data Format options of Report Studio, you can only choose to display the negative numbers in brackets. You cannot specify to show them in different colors. Hence, we have to create a conditional variable here and define the foreground color accordingly.
There was this big limitation in Report Studio up to version 8.2. Imagine that you have 15 numerical measures to be formatted in a similar way. In such case, you need to create 15 conditional variables and assign them to each column. This problem is solved with a new feature introduced in version 8.3 onwards. Please refer to the next recipe for this.
- Beginning Swift
- Hi!扁平化Photoshop扁平化用戶界面設(shè)計(jì)教程
- Wordpress 3 Complete
- 板繪教室:SAI零基礎(chǔ)日系動(dòng)漫插畫入門教程
- WordPress Theme Design
- 有趣的Flutter:從0到1構(gòu)建跨平臺(tái)App
- 學(xué)摳圖:Photoshop專業(yè)摳圖技法案例教程
- 會(huì)聲會(huì)影視頻編輯實(shí)戰(zhàn)秘技250招
- Visio圖形設(shè)計(jì)從新手到高手(兼容版)
- ASP.NET Core 3從入門到實(shí)戰(zhàn)
- AutoCAD 2022中文版從入門到精通(標(biāo)準(zhǔn)版)
- 中文版Photoshop CS6完全自學(xué)手冊(cè)(超值版)
- CAD/CAM應(yīng)用教程
- 零基礎(chǔ)學(xué)Photoshop CS6(全視頻教學(xué)版)
- UG NX 12.0中文版實(shí)戰(zhàn)從入門到精通