Welcome to MSDN Blogs Sign in | Join | Help

Using RDL expressions in Report Builder

While not a documented feature, you actually can enter an arbitrary RDL expression into a textbox in a Report Builder report. For example, you could add a textbox that shows the date the report was run by setting the value of the textbox to the following:

   =String.Format("Date: {0:MM/dd/yyyy}", DateTime.Today)

Another potential use of this undocumented feature is to display the values selected by the user for each report parameter. This is a helpful workaround for the fact that the auto-generated filter description does not insert the run-time values for each parameter. Here's an example of an RDL expression that would provide this info:

   =String.Format("Sales Year: {0}", Parameters!OrderYear.Value)

Note that you will have to guess the name of the report parameter generated by Report Builder. Typically it will be the name of the field used in the prompted filter condition, with any spaces removed.

You cannot enter an RDL expression directly into a detail or subtotal cell in a table or matrix.

Published Sunday, March 26, 2006 3:57 AM by bobmeyers
Filed under: ,

Comments

# re: Using RDL expressions in Report Builder

Friday, October 27, 2006 6:17 AM by PhilNicholas

This is so useful I can't believe its not in the help for report builder!

# re: Using RDL expressions in Report Builder

Monday, October 30, 2006 4:35 AM by PhilNicholas

Found an issue on a lookup parameter, returned the  parameter text for a lookup table and junk was returned. Works fine for text, dates etc. Any ideas.

# re: Using RDL expressions in Report Builder

Friday, November 10, 2006 7:54 AM by PhilNicholas

I needed to use the .Label property as the value would be the id, a little confusing as the id was garbled up as AAC.AAA.

# re: Using RDL expressions in Report Builder

Saturday, February 17, 2007 5:31 PM by Helen W

Any updates on how you can do this with a look-up parameter?

thx

Helen

# re: Using RDL expressions in Report Builder

Saturday, May 26, 2007 7:56 AM by saigalrohit4u

Can we decide the navigation for subtotal in some way ? I couldn't do this so I added my textbox in the subtotal region but its contents are not displayed at all and default subtotal is not taking me to the correct drilldown

# re: Using RDL expressions in Report Builder

Wednesday, October 10, 2007 3:32 PM by Eric_

I want to use a relative date filter and reference the value in the text box.  For example, I want to run the report based on data from last month.  So I create a filter "Issue Date in last 1 months", which gives me the data I'm looking for.

However, when I try and reference the parameter in a text box I get an error ("...refers to a non-existing report parameter 'IssueDate'") when I use: "=parameters!IssueDate.Value".

To further confound the issue, I don't want to see the actual parameter value (which would be "1").  Instead I want to see the month name that the parameter is referring to.

Is this possible?

# re: Using RDL expressions in Report Builder

Friday, March 14, 2008 10:31 AM by LisaO

Can you use expressions in the column and row headers in RB?  I am running a matrix to show hours by month, but the "Month" date variation is an integer value- I want to show the month name.  I had limited success creating a new field and using a nested if statement i.e;

IF(Month = 1, "January", IF(Month = 2, "February"...

but there seems to be a limit to the number of nestings.  And of course the then the months are sorted alphabetically by name--- HELP!!!!

# re: Using RDL expressions in Report Builder: To LisaO...

Sunday, March 16, 2008 12:44 PM by jarretf72

you should try a switch statement. I just found it searching on another blog. It seems to be working really well....

=Switch(Fields!score.Value>=Fields!evaluation.Value,"PaleGreen", Fields!score.Value>0,"Yellow")

# re: Using RDL expressions in Report Builder

Friday, April 25, 2008 7:31 AM by SNGATESON

LisaO

i had a similar problem with the dates in a chart.

Use this formula worked fine for me:

SWITCH(MONTH=1, "JANUARY", MONTH=2 ,"FEB",MONTH=3, "MAR")

hope this helps

# re: Using RDL expressions in Report Builder

Friday, April 25, 2008 7:38 AM by SNGATESON

Following this i still can't find a way to sort the dates not by alphabetically

HELP!?

# re: Using RDL expressions in Report Builder

Tuesday, January 20, 2009 12:37 PM by rduclos

An easier way to display the Month Name would be to use the expression "=MonthName(#)" (# 1 through 12). Then sort the data by the number rather then the Name you could use expression "=Month(YourDate)".

# SQL Reporting "How to" - Color coding based on Data Values: for Tables & Charts. 1/n

Friday, January 30, 2009 7:52 AM by Dave does Data

This "How to" guide provides code samples & ideas on using color to improve your users

# re: Using RDL expressions in Report Builder

Thursday, June 11, 2009 7:49 AM by Pajer

Hi

Using this string

=String.Format("Date: {0:MM/dd/yyyy}", DateTime.Today)

Is it possible to do it so that it creates the previous days date?

Anonymous comments are disabled
 
Page view tracker