Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Siva_Prakash_S
Explorer
1,514

Hi SAP community!

I'd like to present a solution for conditionally styling the totals and subtotals in a table based on styling rules rather than hardcoded approach.

Problem Statement: 

Consider this scenario where the customer wants to see the totals and subtotals highlighted in a separate color. In a static scenario where the rows don't change, we can apply the colors manually by cell styling. However, in most cases the rows in the table always change based on the members. So, in order to tackle a changing table dynamically, we need to opt for styling rules. Not only is styling rules dynamic, but it also has better performance than manual cell styling.

Solution:

In order to handle the requirement, I have created a few styles and styling rules for the totals and subtotals of the table.

Siva_Prakash_S_0-1736238909649.png

Based on the above screenshot, we can see that the totals, subtotal each have their own row color.

In order to achieve this, 
Create a story in SAC and insert a table
Siva_Prakash_S_1-1736238909652.png

I am using the sample model provided by SAP BestRunJuice_SampleModel for this blog. You can follow the exact same steps to replicate it.

Siva_Prakash_S_2-1736238909660.png

Add the dimensions Product, Location and Sales managers in the row and Date dimension in the columns.

Siva_Prakash_S_3-1736238909674.png

Enable Totals for each of the row dimensions.Siva_Prakash_S_4-1736238909683.png

Siva_Prakash_S_5-1736238909688.png

Siva_Prakash_S_6-1736238909692.png

Siva_Prakash_S_7-1736238909698.png

Create 3 separate styles for each of the totals.
Firstly, let's create a style for the totals with a green color fill and black bold text.

Siva_Prakash_S_8-1736238909701.png

Secondly, Create a style for the second totals. I'm using a yellow fill to distinguish the overall totals with the subtotals.

Siva_Prakash_S_9-1736238909702.png

And we shall create one more style for the lowest level subtotal with an orange fill and white text.

Siva_Prakash_S_10-1736238909704.png

Create one more style for the data members with a dark black text.

Siva_Prakash_S_11-1736238909705.png

Then create styling rules for each of the 3 totals and the data members.

2.png

 For the overall totals, create a styling rule using the Totals style which we had initially created.

Then enable the 'Hand' based selection tool and choose the following checkboxes as depicted below.
3.png

 

 

 

 

 

 

 

 

Enabling the above checkboxes will affect the styling only to the data and header of the selected dimensions.

Click on the measure value '235.04' as shown in the below screenshot by the highlighted box, which is on the same row as the overall totals. By doing so, the content analyzer will automatically detect the zone at which the styling needs to be applied.

Siva_Prakash_S_12-1736238909712.png

On selecting ok button, the Totals styling will be applied in the table.

For the next subtotals, Click on the measure value '34.03' as shown in the below screenshot. On doing so, the content analyzer will carefully detect the zones at which this needs to be applied.

One additional thing we need to do is to select the level as 'Self & Sibling' for Product and Sales manager.
This property will make the styling repeat for every other instance where the subtotal occurs.

Siva_Prakash_S_13-1736238909722.png

The styling rules at the top will overrule the one listed below. It behaves the same way as a stack or an array would.
In this case, since the subtotals rule is above the totals rule, the green rule is getting overruled by the yellow rule.

Overlapping of styling ruleOverlapping of styling rule

 

Rearrange the styling rules based on the order of precedence.

Once we have Totals > Subtotals we will get our favorable output.

Siva_Prakash_S_15-1736238909736.png

Now, we need to repeat the same for the next level of subtotals which is the Sales Manager level subtotal.

Select the checkboxes and Levels as mentioned in the screenshot below.

Siva_Prakash_S_16-1736238909744.png

Similarly, the Styling rule sequence needs to be rearranged.

Siva_Prakash_S_17-1736238909751.png

Once we have Totals > Subtotals > lowest level we will get our favorable output.

Siva_Prakash_S_18-1736238909758.png

Finally, we can also set a styling rule for the data members.
For this, select the entire data range as shown in the screenshot below. Also choose the checkboxes and Levels appropriately.

Siva_Prakash_S_19-1736238909774.png

Again, we need to rearrange the sequence.

Siva_Prakash_S_20-1736238909789.png

Once we have Totals > Subtotals > lowest level> Members we will get our favorable output.

Siva_Prakash_S_21-1736238909799.png

If we preview the final look in the Fullscreen, we can observe that the styling rules are repeating for every dimension member combination.

Siva_Prakash_S_22-1736238909803.png

This method will improve the performance by eliminating manual cell styling.
Always go for styling rules wherever possible.

Siva_Prakash_S_23-1736238909813.png

Hope this blog was helpful, if you have any doubts, you can always drop a comment below.

With regards,
Siva prakash.

 

 

 

 

2 Comments