Partager via


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.

Comments

  • Anonymous
    October 26, 2006
    This is so useful I can't believe its not in the help for report builder!
  • Anonymous
    October 29, 2006
    The comment has been removed
  • Anonymous
    November 09, 2006
    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.
  • Anonymous
    February 17, 2007
    Any updates on how you can do this with a look-up parameter?thxHelen
  • Anonymous
    May 25, 2007
    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
  • Anonymous
    October 10, 2007
    The comment has been removed
  • Anonymous
    March 14, 2008
    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!!!!
  • Anonymous
    March 16, 2008
    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")
  • Anonymous
    April 24, 2008
    LisaOi 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
  • Anonymous
    April 24, 2008
    Following this i still can't find a way to sort the dates not by alphabeticallyHELP!?
  • Anonymous
    January 20, 2009
    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)".
  • Anonymous
    January 29, 2009
    This "How to" guide provides code samples & ideas on using color to improve your users
  • Anonymous
    June 10, 2009
    HiUsing 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
    July 13, 2011
    how to check is the string a substring in other stringlike Contains(Parameters!ReportParameter1, "1").ToString()