Months and Trailing Twelve Months in One Table (2024)

Months and Trailing Twelve Months in One Table (1)

The Request

Use a disconnected table in Power BI to show each month and total trailing twelve months (TTM), the total for prior TTM, AND the variance between the two in one matrix table. Why?I saw a request for this kind of report in the Power BI Community forums. The requester also wanted the totals row to show the average for each column and to have conditional formatting for each cell, based on being above or below average.

Please click here to download the .pbix and follow along.

Disconnected Table for Pre-Arranging the Data

My solution is to create a table in the data model to pre-arrange the data. Each row provides a date range for the data, an offset value, and a name for the range. In the final report these rows will provide the column headers. From the Modeling tab in Power BI, I use the Create New Table button to create a table:

Report = GENERATESERIES(-11, 3, 1)

This GENERATESERIES() function creates a one-column table with values from -11 to +3. I then add some calculated columns to the table. I start with End Date and work from there.

EndDate =
VAR LastFullMonth = IF(TODAY()=EOMONTH(TODAY(),0),
TODAY(), EOMONTH(TODAY(), -1))
RETURN
IF (
Report[Value] < 1,
EOMONTH(LastFullMonth,Report[Value]),
IF (
Report[Value] = 1,
LastFullMonth,
IF ( Report[Value] = 2, EOMONTH ( LastFullMonth, -12),
LastFullMonth
)

EOMONTH() finds the last day of the month. The second argument tells the function how many months to go back. The LastFullMonth variable uses the last day of the previous month, or the current day if it’s the last day of the month. Each of the month rows uses the Report[Value] column as an offset. 0 is the current month (last full month). -1 is the prior month, and so forth. The positive values give us our last three columns. Report[Value] of 1 is the end of the twelve trailing months. Report[Value] of 2 is the end of the prior twelve trailing months. And Report[Value] of 3 is the Variance (so end date doesn’t really matter here).

The Second column is Start Date. Start Date uses the End Date to get the first day of the month for each month.

Start Date = IF(Report[Value] <1, DATE(YEAR(Report[EndDate]), MONTH(Report[EndDate]), 1),
EOMONTH(Report[EndDate], -12)+1)

For the last 3 columns, Start Date goes back 12 months + 1 day, to get the beginning of the 12 month period.

The third added column is Range, which is the column name. It’s the end date of the month, or TTM, TTM LY, or Variance.

Range = IF(Report[Value] < 1, FORMAT(Report[EndDate],””),
IF(Report[Value] = 1, “TTM”,
IF(Report[Value] = 2, “TTM LY”, “Variance”)
)
)

From the modeling tab, be sure to set the sort by column for Range to the Value column.

The table looks like this in Data View of Power BI:

In Data View, it’s easy to verify that the date ranges are as expected. Report[Value]: 0 is the current last full month, which starts with 12/1 and ends with 12/31. TTM and TTM LY both have the expected start and end as well.

DAX Measures:Trailing Twelve Months (TTM) in Power BI

The data ranges of the Report table will feed the measures for our report.PdSales gets the Total Sales – Sum(Sales[Sales Amount]) for the dates between the Start Date and the End Date from the Report table. This measure works not only for the individual months, but also for TTM and TTM LY.

PdSales = CALCULATE (
[Total Sales],
DATESBETWEEN (
‘Calendar'[Date],
MIN ( Report[Start Date] ),
MAX ( Report[EndDate] )
)
)

The only thing that PdSales doesn’t account for is the Variance, because it doesn’t use a date range. Variance is the difference between TTM and TTM LY, or between Report[Value]=1 and Report[Value]=2.

Variance =
CALCULATE([PdSales],
ALL(Report),
Report[Value]=1)

CALCULATE ([PdSales],
ALL(Report),
Report[Value]=2
)

The CALCULATE statements get the difference between [PdSales] for TTM and TTM LY.

A measure called [Period Sales] brings these two measures together.

PeriodSales =
IF(MAX(Report[Value]) < 3,
[PdSales],
[Variance]
)

The final measure gets the average of the Period Sales according to the Region.

Average Period Sales =
AVERAGEX(VALUES(Territories[Region]), [PeriodSales])

This will return [Period Sales] for each region, but for the grand total it will find the average of [Period Sales] for the Regions.

Bring It All Together in a Matrix Visual in Power BI

Put Territory[Region] on Rows. Put Report[Range] on columns. And put [Average Period Sales] on values.Now, that’s an elegant solution. If the columns are in the wrong order, go to the modeling tab and set the sort by column for Report[Range] to Report[Value]. Sadly, there’s not a way to set conditional formatting for each column of a matrix based on the total row. But, that’s not going to stop us!

You can, however, add a measure to show the percentage of the total, and put conditional formatting on that.I then size the column to be too narrow to show the number, so that only the background color is visible.

Above or Below Average =
[Average Period Sales] / CALCULATE([Average Period Sales], ALL(Territories) )

[Above or Below Average] goes into values in the fields well of the matrix. Click on the field in the wells to set Conditional Formatting: Background color scales.

The values shown are what I prefer to keep the chart clean and highlight significant differences. What stands out are values that are 50% or less of the total shown or 150% or greater of the total. I also did not want the name of the Sales measure repeating for each column, so I renamed in to a single space in the field wells.

What Else? Slicers, a Ribbon Chart, and Bookmarks

I added slicers, true slicers, to the page. And as Rob has said, “it’s not a ‘legitimate’ post until a slicer shows up.” What do I mean by a true slicer? I mean buttons, and not dropdowns. To get these guys, you have to select General under the formatting options and choose Vertical. Once you do that an option shows up to make the slicer responsive. Then you can fiddle with the sizes until they look better. They may not be easy to work with, but people LOVE them.

A Ribbon Chart to Give Context to the Matrix

My report consumers ask for a lot of tabular visualizations. It’s because they can export it to Excel. But tables don’t always show patterns in the clearest way, so I added a ribbon chart to the page, to add context. I like to use the legend as a slicer, but I don’t like the default highlighting when clicking on the legend of a ribbon chart. It’s way too subdued for my taste. Instead, I prefer what it looks like when you click another chart and can see that one thread go all the way through the months (not just the data points but also the transitions between them). So, I added a bar chart below the ribbon chart and sized it so that the bar chart is not visible, but the legend for the bar chart is visible.

Bookmark: All Twelve Trailing Months

So, only 9 months are displayed on my matrix table. With the slicers and extra conditional formatting, I can only fit in 9 of the twelve trailing months. I use the filter pane in Power BI to filter the Report[Value] to -9 or greater. So, I bookmarked a second copy of the report (and a second copy of the ribbon chart). The report reader can click the Twelve Months button, see the tables widen, and slicers disappear. The Twelve Months button is actually a rectangle shape with no fill. Behind that shape is a text box with a white fill that has the text of Twelve Months (details at the end of the post).

Above is my Bookmarks pane and Selection pane. Every item in my Selection Pane has a name. I get this result by adding a title to every element and in most cases turning that title off. This makes it much easier for me to decide what to show or hide in the bookmark. The Original View is the bookmark for the default, with slicers and limited months. Wide View is the bookmark for showing all twelve trailing months, with no slicers. Wide View has Data turned off, so that all of the slicers from the Original View will carry over when the user clicks the Twelve Months button.

So, how do bookmarks impact mobile versions of reports?

Mobile versions of reports are critical for supporting managers and executive officers to check on key metrics no matter where they are. And for that matter, they can be useful for outside sales reps. When I say mobile, I mean the portrait version, because landscape just looks like the report. There’s less screen space, so it forces you to think about what’s most important. In my case, I have decided that what’s most important are the slicers and the totals: the total for the twelve trailing months, the total for the previous twelve, and the variance.

Bookmarks don’t actually work in the mobile portrait view. The items visible are whatever items are visible in the default view of the page. If an element is not visible in the default view, it will be invisible when added to the mobile view. The bottom line is that if something needs to be visible on the mobile view, it has to be visible in the default view of the page. But I don’t really want to show both versions on my page. What to do? Make it visible, but make it tiny and hide it behind something else on the page. In my case, I sized it to be too small to read in the standard view of the report, and I put it in the same space as. On the mobile version, I add it to the canvas and resize it as I like.

My three-layered button

Back layer: Table for mobile report.

This table is small enough now to be hidden behind the button.

Middle layer: text for my button.

The text box is formatted with an opaque white background, to conceal the tiny table.

Top layer: a rectangle shape

This shape is transparent, so that the text from the text box shows in the middle of the rectangle. This link to the bookmark is anchored to this shape. To move elements forward or back, select the item by clicking on it, and select format in the ribbon and move forward or back.

Where It’s At: The Intersection of Biz, Human, and Tech*

We “give away” business-value-creating and escape-the-box-inspiring content like this article in part to show you that we’re not your average “tools” consulting firm. We’re sharp on the toolset for sure, but also on what makes businesses AND human beings “go.”

In three days’ time imagine what we can do for your bottom line. You should seriously consider finding out 🙂

* – unless, of course, you have two turntables and a microphone. We hear a lot of things are also located there.

As an expert in Power BI and data visualization, I've successfully implemented intricate solutions to meet complex reporting requirements. I've not only mastered the technical aspects of Power BI but also developed a keen understanding of creating insightful and user-friendly reports.

Now, let's delve into the concepts used in the provided article about creating a Power BI report with a disconnected table, trailing twelve months, and conditional formatting:

  1. Disconnected Table for Pre-Arranging the Data:

    • GENERATESERIES Function:
      • The GENERATESERIES() function is used to create a one-column table with values from -11 to +3, representing the months.
    • End Date Calculation:
      • The EOMONTH() function is employed to find the last day of the month, considering the offset provided by the Report[Value] column.
  2. DAX Measures:

    • Trailing Twelve Months (TTM):
      • The PdSales measure utilizes CALCULATE and DATESBETWEEN to get the total sales for the specified date range.
    • Variance:
      • The Variance measure calculates the difference between TTM and the prior TTM using the CALCULATE and ALL functions.
    • Period Sales:
      • The PeriodSales measure combines PdSales and Variance based on the value in the Report[Value] column.
    • Average Period Sales:
      • The Average Period Sales measure calculates the average of PeriodSales for each region.
  3. Matrix Visual in Power BI:

    • The matrix visual is used to display the data, with Territories[Region] on rows, Report[Range] on columns, and [Average Period Sales] on values.
    • Sorting is adjusted in the modeling tab to ensure the correct order.
  4. Conditional Formatting:

    • Above or Below Average:
      • The [Above or Below Average] measure is created to determine the percentage of the total and is used for conditional formatting based on background color scales.
  5. Slicers, Ribbon Chart, and Bookmarks:

    • Slicers:
      • True slicers (buttons) are added for user interaction, allowing them to filter data conveniently.
    • Ribbon Chart:
      • A ribbon chart is included to provide context to the matrix visual, enhancing data interpretation.
    • Bookmarks:
      • Bookmarks are used to create alternative views, such as displaying all twelve trailing months, and are managed through the Power BI interface.
  6. Mobile Version Considerations:

    • Bookmarks are explained to provide insights into their impact on mobile versions of reports, emphasizing the importance of visibility in the default view for elements to appear in the mobile portrait view.

In conclusion, this article demonstrates a comprehensive approach to creating an effective Power BI report, combining data modeling, DAX measures, visualizations, and user interaction elements to meet specific reporting requirements.

Months and Trailing Twelve Months in One Table (2024)

FAQs

How do you calculate trailing 12 months? ›

TTM takes into account the trailing twelve months of financial data, providing a comprehensive view of a company's recent performance and trends. TTM is calculated by adding up the financial data from the four most recent quarters and can include metrics such as revenue, net income, and earnings per share.

What is the trailing 12 months balance sheet? ›

Trailing 12 months (TTM) is the term for the data from the past 12 consecutive months used for reporting financial figures. A company's trailing 12 months represents its financial performance for a 12-month period; it does not typically represent a fiscal-year ending period.

What is an example of a trailing 12-month date? ›

Trailing 12 Months Examples

For example, assume the date is sometime in January 2023. The TTM would be January 2022 – December 2022, regardless of when in January 2023 it is. The TTM for February 2023 would be February 2022 – January 2023. During November 2023, the TTM would be November 2022 – October 2023.

Are TTM and LTM the same? ›

Is LTM and TTM the same? LTM (or 'Last Twelve Months') and TTM ('Trailing Twelve Months') are interchangeable. Both reflect the most recent Twelve Months of Financial performance for a Business.

What is the difference between annualized and trailing 12 months? ›

Trailing twelve months refers to a company's financial data over the past 12 months and should not be confused with annual data which a company reports at the end of each accounting year. TTM numbers can be calculated at any point in time during a year unlike annual data, which is reported only once during a year.

How to calculate 12 months? ›

First, find the starting date on the calendar, then advance the calendar one month at a time until you've counted 12 months. Instead of counting up, you can move forward one month at a time while subtracting 1 from 12 for each month you move forward.

What is the trailing 12 months multiple? ›

The TTM multiple refers to the multiple applied to the trailing or last 12 months of a specific financial metric such as the revenue, net earnings, or EBITDA of a company.

What is a 12 month rolling P&L? ›

A rolling profit and loss is just the last full 12 months (wherever you are at in the year) of the business's profit and loss. The months used should be completed and reconciled before being included in the rolling profit and loss statement, to ensure accuracy.

What is the difference between trailing 12 months and last 12 months? ›

Last twelve months (LTM) refers to the timeframe of the immediately preceding 12 months. It is also commonly designated as trailing twelve months (TTM). LTM is often used in reference to a financial metric used to evaluate a company's performance, such as revenues or debt to equity (D/E).

How do you calculate trailing? ›

Understanding Trailing Price-To-Earnings (P/E)

It is calculated by dividing the current market value, or share price, by the earnings per share (EPS) over the previous 12 months.

Does trailing 3 months include current month? ›

Trailing 3 Month Period means, for any specified date, the three (3) month period ending with the later of (i) the last day of the most recent Calendar Quarter or (ii) the month for which financial statements have been delivered by Borrower to Fannie Mae pursuant to Section 2.04 and Section 6.03.

What is the last 12 months revenue? ›

What is LTM Revenue? LTM stands for “Last Twelve Months” and is similar in meaning to TTM, or “Trailing Twelve Months.” LTM Revenue is a popular term used in the world of finance as a measurement of a company's financial health.

Is LTM a gaap term? ›

The LTM EBITDA metric refers to a company's EBITDA as of the most recent four quarters, i.e. the last 12-month period. EBITDA is a non-GAAP metric that measures a company's core operating cash flows.

How do you calculate 12 month rolling sum? ›

The 12-month rolling sum is the total amount from the past 12 months. As the 12-month period “rolls” forward each month, the amount from the latest month is added and the one-year-old amount is subtracted. The result is a 12-month sum that has rolled forward to the new month.

How do you calculate 12 months from a date? ›

First, find the starting date on the calendar, then advance the calendar one month at a time until you've counted 12 months. Instead of counting up, you can move forward one month at a time while subtracting 1 from 12 for each month you move forward.

How to calculate 12 month return? ›

Find the difference between the beginning and ending values for each year. Subtract the value of the portfolio at the beginning of the year from the value of the portfolio at the end of the year, then divide that number by the value at the beginning of the year. This is your simple, or basic, rate of return.

Top Articles
Latest Posts
Article information

Author: Kareem Mueller DO

Last Updated:

Views: 6208

Rating: 4.6 / 5 (66 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Kareem Mueller DO

Birthday: 1997-01-04

Address: Apt. 156 12935 Runolfsdottir Mission, Greenfort, MN 74384-6749

Phone: +16704982844747

Job: Corporate Administration Planner

Hobby: Mountain biking, Jewelry making, Stone skipping, Lacemaking, Knife making, Scrapbooking, Letterboxing

Introduction: My name is Kareem Mueller DO, I am a vivacious, super, thoughtful, excited, handsome, beautiful, combative person who loves writing and wants to share my knowledge and understanding with you.