How can I set formatting for the table of contents?

2 posts, 0 answers
  1. Frank
    Frank avatar
    9 posts
    Member since:
    Feb 2019

    Posted 08 Feb Link to this post

    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?

  2. Frank
    Frank avatar
    9 posts
    Member since:
    Feb 2019

    Posted 14 Feb Link to this post

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

    I did not know.
    Thanks for your help.

Back to Top