Cognos Analytics

 View Only

Reusing Conditional Styles in Reports

By Marc Reed posted Tue March 19, 2024 05:24 AM

  

I was thinking of titling this blog post Conditional, Conditional, Conditional Styles. But the purpose of the post is to show that I only need one Conditional style...

Reusing Conditional Styles Within Reports

Conditional styles are a great way of drawing attention to information within a report. Consider this simple top 10 report:

The report has two lists. Both showing Revenue for 2015 and 2016 and the Revenue change between years. Both lists show the Top 10 2016 Revenue. The list on the left if for all data for top 10 products 2015/2016. The right list however is filtered on Department stores and shows the Top 10 retailers.

Remember that most important question for any report author when writing a report for someone: “…and what do you do next?”. After asking this question, it transpires the report consumer wants to know which entries in the top 10 have increased or decreased revenue between the years. They do this by scanning the Change in Revenue column looking for positive and negative values.

As a report author I know a conditional style on the Change in Revenue column would make the movers and losers easily stand out.

Within the report I will add a conditional style to the left-hand list:

When I add a new advanced condition to the conditional style, I am presented with the report condition dialogue box to define the expression definition.

This report has two queries, one for the left list and one for the right. As the two lists have different filters (the left list is for all data, the right list is filtered on department stores) a different query is needed for each list.

As I am working on the left-hand list, I know I must choose the Change in Revenue from the Top 10 Products query.

The final conditional style ends up looking like:

The report now looks like:

I now need to apply a similar conditional style to the right-hand list. This conditional style is the same as that I have already applied. I can use that as my starting point.

If I open the manage conditional styles window:

Bonus tip: I can copy the existing style using the windows shortcuts of ctrl-c and then ctrl-v.

I can then edit Change in Revenue1 to make it applicable to the right-hand list, and then apply it to the right-hand list.

I now have two conditional styles within my report. One for the left list, and one for the right.

The only difference is which query each conditional style is using. Surely, there must be a better way.

Reusing a Conditional style

Let’s back up to when I made the first conditional style.

When an item is dragged from the Available Components into the Expression Definition it is qualified with the query name.

Within the editor I can remove the query qualification from the expression.

I can repeat that for all the expressions within this conditional style.

This makes this conditional style query independent. As both queries used within this report have measures called ‘Change in Revenue’ then this single conditional style can be applied to both lists.

Bonus tip: I remove the query qualifier when I create any conditional style. Why? When developing a report, I often rename queries. If I rename a query, I don’t then have to update any conditional styles I have created.

Conditional Styles and Classes

Whilst I have your attention, conditional styles can also Classes for formatting. Often people will create conditional styles using bespoke formatting, such as setting font colours and background colours on each condition.

I would urge you to look at using classes for any kind of formatting – even conditional styles. By defining the formatting as a class it allows for reuse and much simpler editing. If a format needs to be changed, then only the class needs to be updated, rather than all the individual formats.

Local classes are defined within the classes part of the report.

Classes can either be applied to individual objects on the classes property, or within a condition style:

Resulting in a less garish report:


#IBMChampion
#CognosAnalytics
#IBMCognosAnalytics
2 comments
29 views

Permalink

Comments

Tue April 16, 2024 09:18 AM

Thank you Marc. Very useful as usual!

Mon April 01, 2024 08:52 AM

Great share Marc!