This is a migrated thread and some comments may be shown as answers.

How can I set formatting for the table of contents?

1 Answer 174 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 08 Feb 2019, 12:22 PM
Hello,

I've created a report that displays entries grouped by different time periods (year, month, week, ...) in multiple levels.
As a caption for these layers, I have each created a date field that will be displayed in a matching format.
For example, MM.yyyy (MMM.) For month, will be formatted as follows: 01.2018 (Jan).
I also use the groups in my table of contents.
For this I have created corresponding levels and deposited in the group editor in each case a TocText as an expression.
That works so far everything, but is sometimes very complicated.
If you want to have a formatting as above that is very expensive.
The expression looks like this:

The simple variant
= IIf (Len ("" + Fields.ticket_closed_at.Month) < 2,
    "0" + Fields.ticket_closed_at.Month,
    Fields.ticket_closed_at.Month
    ) + "." + Fields.ticket_closed_at.Year

That's easy.
But if you also want the month in short form, as above, I have the following expression:

= IIf (Len ("" + Fields.ticket_closed_at.Month) < 2,
    "0" + Fields.ticket_closed_at.Month,
    Fields.ticket_closed_at.Month
    ) + "." + Fields.ticket_closed_at.Year
 
    + "(" +
 
    IIf (Fields.ticket_closed_at.Month = 1, "Jan",
        IIf (Fields.ticket_closed_at.Month = 2, "Feb",
            IIf (Fields.ticket_closed_at.Month = 3, "Mar",
                IIf (Fields.ticket_closed_at.Month = 4, "Apr",
                    IIf (Fields.ticket_closed_at.Month = 5, "May",
                        IIf (Fields.ticket_closed_at.Month = 6, "Jun",
                            IIf (Fields.ticket_closed_at.Month = 7, "Jul",
                                IIf (Fields.ticket_closed_at.Month = 8, "Aug",
                                    IIf (Fields.ticket_closed_at.Month = 9, "Sep",
                                        IIf (Fields.ticket_closed_at.Month = 10, "Oct",
                                            IIf (Fields.ticket_closed_at.Month = 11, "Nov", "Dec")
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    ) + ".)"

That works, but nice is different.
And if you still want to localize it is over.
My question on you is:
Is there a way to apply formatting to TocTexte, such as on a text box?
Or maybe there is another way how to solve something?

1 Answer, 1 is accepted

Sort by
0
Frank
Top achievements
Rank 1
answered on 14 Feb 2019, 08:34 AM

Have found the solution:
= FormatWithCulture( "de", "{0:MM}.{0:yyyy} ({0:MMM})", Fields.ticket_closed_at )

I did not know.
Thanks for your help.

Tags
Report Designer (standalone)
Asked by
Frank
Top achievements
Rank 1
Answers by
Frank
Top achievements
Rank 1
Share this question
or