Year-To-Date & Month-To-Date Calculations Made Easy

As a consultant, I find that the majority of the projects I work on these days involve the need to compare data over a specific time frame. For instance, how have my sales compared year-to-date compared to last year’s year-to-date. While the functionality has always existed in m-Power to accomplish such a task, Calculations now support this functionality built in directy to m-Power. This tech blog is going to illustrate how to use this feature.

Before we dive in, I want to point out that this feature is only available in Report and Summary templates. This was done because this functionality is most suitable for totaling. Additionally, this feature requires the use of a true date field. If you utilize numeric or character dates, please convert them first (either by a UDF, a previous calculation, a date transportation table, etc…).

Creating a Year-To-Date Calculation

Let’s create a new report, I’ll select the fields “Product”, “Sale Date”, and “Sales Amount”. Since I want a yearly comparison on product, I will sequence (and sub-total) by Product. Once that is done, head to the calculation screen. In the “Calc Type” drop-down list, select “MTD/YTD”.

As with other calculations, add a description and set the length and decimals accordingly.

  • Since we want a YTD calculation, leave the “Date Range Type” as the default.
  • Be sure “Apply to Field” is set to the value you want totaled/computed.
  • In the “Date Field” dropdown, please select your true-date field. If no fields are available, you have not selected a true-date field for this application.
  • In the Number of Years back, set the value here for how many years back to examine. For instance, 0 would look at the current YTD. 1 would look at last year’s YTD, etc…
  • If your organization utilizes a fiscal year that is different than the traditional calendar year, be sure to specify the first day of your calendar year. For instance, if your fiscal year begins July 1st, you would specify 07/01.
  • Once completed, you will be taken back to the “Calculation Review” screen. From here, I would recommend copying the calculation you just created. Next, edit the newly copied application. Be sure to modify the calculation description, usually from “Current Year Sales” to something like “Previous Year Sales.” Most importantly, modify the “Number of Years Back” value from 0 to 1. After saving, you will be returned to the “Calculation Review” screen once again.

    Notice in the above calculation, the only difference beyond the description is the 3rd parameter listed (the # of years back). As a bit of house keeping, I would recommend, hiding the original field (In my case, Sales Amount) as well as your date field within field settings. When you run your application, it will look something like this:

    At run time, m-Power automatically detects today’s date, then applies the necessary date ranges to compute the correct values.

    Creating a Number of Days Back Calculation

    While YTD and MTD behave similarly to one another, the other option a developer has is creating a “Number of X Days” calculation.

    To create, follow the instructions set out above, except select “Last x Days” from the “Date Range” dropdown. You will still need to choose the “Apply to Field” and “Date Field” values. However, you will need to select the number of days back to analyze as well as the number of years back. Typically, a common approach would be creating 3 calculations (30 day history (this year), a 30 day history last year, and a 30 day history from 2 years ago) view. A useful aspect of this report is that it will allow you to easily compare the exact same time periods over distinct years, leveraging key business trends.

    No matter which option you choose, be mindful that each different grouping of time (column) requires its own calculation.

    Related Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *