• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Blog
  • Power Platform
    • Power Apps
    • Power Automate
    • Power BI
    • Power Virtual Agents
  • Dynamics 365
  • Azure
  • About Me
Joe Gill Logo

Joe Gill

Microsoft MVP - Power Platform Consultant

Home » SQL » Conditional Formatting in Reporting Services using Common Code

Conditional Formatting in Reporting Services using Common Code

29th July 2009 by Joe Gill Leave a Comment

The lack of support for CSS style sheets in reporting services can make life difficult when you want to have common formatting across reports. There are also occasions where you may want to share common conditional formatting logic across reports. This example shows how common code can be used to help in these scenarios.

Whilst a .NET assembly would probably be more efficient not everybody is in a position to write and deploy .NET assemblies.



The first example simply sets the background color of a textbox based on the value of a variable.

In this example the textbox background is set to red if the value is less than 50 otherwise it is set to green. This logic may be required in multiple textboxes in a single report or across multiple reports.

Open your report and under properties add the following to the code



Conditional Formatting in Reporting Services using Common Code Joe Gill Dynamics 365 Consultant function StopGoColor(d as decimal) as string

StopGoColor = iif(d < style="font-family:arial;">end function





Select the textbox where you want apply the conditional formatting and enter the following expression for the fill color using your own value to pass to the function

=Code.StopGoColor(Fields!SalesPercent.Value)

Conditional Formatting in Reporting Services using Common Code Joe Gill Dynamics 365 Consultant

This function can be used through out your report to ensure consistant formatting.

Once you have written the functions you require you can create a report template by copy the code into an empty report and saving this report into the C:Program FilesMicrosoft Visual Studio 9.0Common7IDEPrivateAssembliesProjectItemsReportProject direcory.

Now when you select Add New you will get the option to base any new report on the newly created template report which already contains your common formatting code.



Share This On Social:
  • Tweet
  • Conditional Formatting in Reporting Services using Common Code Joe Gill Dynamics 365 Consultant

Filed Under: SQL

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Popular Categories

  • Power Platform
    • Power Apps
    • Power Automate
    • Power Virtual Agents
  • Azure
    • Logic Apps
  • Dynamics 365
  • .NET
  • AI
  • SQL

More to See

Power Platform Requests – Base Request Capacity

17th December 2020 By Joe Gill

Power Automate Desktop

Power Automate Desktop – UI Flow

26th November 2020 By Joe Gill

Tweets

Footer

Joe Gill

Microsoft Business Applications MVP – Power Platform, Dynamics 365 and Azure.

An architect with over twenty years experience designing and developing technology solutions. Specializing in the Microsoft technology stack including Power Platform, Dynamics 365 and Azure. Microsoft MVP Profile

Connect on Social

Useful Links

  • Home
  • Blog
  • About Joe Gill
  • Power Platform
  • Dynamics 365
  • Azure

Featured Posts

Power Platform Requests – Base Request Capacity

Power Automate Desktop – UI Flow

MB-600 – Solution Architect – Supportability

AI Builder – Form Processing Layouts

© 2021 · Joe Gill