1 Answer 78 Views
Report Designer (standalone)
Top achievements
Rank 1
Jenner asked on 25 May 2021, 03:51 AM
I need to change the column name of the report based on the Day of Week.
I could not find this function on the docs.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 May 2021, 01:21 PM

Hi Jenner,

There are a couple of ways to change the column name based on the current or predefined day of the week.

Option 1: Use expression for the value field of the column name text box

This is the faster approach, but depending on what is your exact requirement it could be insufficient. Anyway, to do this, you will need to:

  1. Open the expression window of the column name textbox - right-click on it and select "Expression..."
  2. There you will have the possibility to write your own logic in order to change the value based on certain DayOfWeek. For example, you can nest several IF operators in order to go through all the days of the week and visualize something different for each one of them:
    =IIf(CStr(Fields.DateCreated.DayOfWeek) = "Monday", "1",
    IIf(CStr(Fields.DateCreated.DayOfWeek) = "Tuesday", "2", 
    IIf(CStr(Fields.DateCreated.DayOfWeek) = "Wednesday", "3", 
    If(CStr(Fields.DateCreated.DayOfWeek) = "Thursday", "4", 
    IIf(CStr(Fields.DateCreated.DayOfWeek) = "Friday", "5", 
    IIf(CStr(Fields.DateCreated.DayOfWeek) = "Saturday", "6", 
    IIf(CStr(Fields.DateCreated.DayOfWeek) = "Sunday", "7", 
    "No day of week recognized!")))))))

Option 2: Add User Function to your report

This is the preferred way to do this, as it provides the full framework capabilities and you can achieve a lot more things in a cleaner and more robust code. Here are the steps to do this:

  1. Create a new .NET Class library inside Visual Studio. Because the Standalone Report Designer is a WPF application built against .NET Framework 4.0, you can use only .NET Framework or .NET Standard 2.0 Class Library.
  2. Add a reference to the Telerik.Reporting assembly.
  3. Create a public static function that will return a string based on a received DateTime object. For example, this one:
    [Function(Category = "DateTime", Namespace = "UserFunction",
              Description = "Returns <string>colors based on the day of the week")]
            public static string ReturnColorsBasedOnDayOfWeek(DateTime dt)
                DayOfWeek dayOfWeek = dt.DayOfWeek;
                switch (dayOfWeek)
                    case DayOfWeek.Friday:
                        return "Blue is the color of " + dayOfWeek;
                    case DayOfWeek.Monday:
                        return "Green is the color of " + dayOfWeek;
                    case DayOfWeek.Saturday:
                        return "Yellow is the color of " + dayOfWeek;
                    case DayOfWeek.Sunday:
                        return "Red is the color of " + dayOfWeek;
                    case DayOfWeek.Thursday:
                        return "Purple is the color of " + dayOfWeek;
                    case DayOfWeek.Tuesday:
                        return "Orange is the color of " + dayOfWeek;
                    case DayOfWeek.Wednesday:
                        return "Brown is the color of " + dayOfWeek;
                        return "Something went wrong!";
  4. Build the solution and copy the produced .dll to the Telerik Reporting Standalone designer folder (by default: "C:\Program Files (x86)\Progress\Telerik Reporting R1 2021\Report Designer")
  5. Open the Telerik.ReportDesigner.exe configuration file.
  6. In it, add an assembly reference, like the following one:
    			<add name="UserFunction" version="" />
  7. Open the Telerik Reporting Standalone Designer
  8. Open the expression window of the column name textbox - right-click on it and select "Expression..."
  9. You should be able to find your new User Function under Functions in the expression window. You can use it and modify it as you wish in order to achieve the exact requirements you may have. Just make sure to copy the newly built .dll file after each change of the class library in Visual Studio.

More about this approach can be found in thе How To Use User Defined Functions in the Standalone Telerik Report Designer tool blog post.

As a side note, if you want to get the current day, you may use the following Expression:" =Now().DayOfWeek"

Additionally, I agree that our documentation can be improved a lot in that area and I have logged this in our backlog. I believe we will be able to address it soon. Thank you for your feedback.

I hope this helps. Please, let us know if you will require further assistance.

Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Report Designer (standalone)
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question