3 easy steps to make a Rolling 12 Months KPI in Power BI

Shashanka Shekhar
Microsoft Power BI
Published in
4 min readFeb 7, 2024

Power BI is a platform that allows you to connect to various data sources, transform and model your data, and create interactive dashboards and reports. Power BI can help you gain insights from your data and communicate them effectively.

What is a KPI?

A KPI, or a key performance indicator, is a measurable target that shows how well an individual or a business is performing in terms of meeting their goals. KPIs can be financial, such as net profit or revenue, or nonfinancial, such as customer satisfaction or retention. KPIs help organizations track their progress, identify their strengths and weaknesses, and make informed decisions to improve their outcomes.

Photo by Alesia Kaz on Unsplash

What are Rolling 12 Months Calculations?

The rolling 12 months calculation, also known as Last Twelve Months (LTM) or trailing twelve months, is a method used to evaluate a company’s performance during the immediately preceding 12-month time period. This is not necessarily related to a fiscal year period, as the LTM references any 12-month period.

Building the KPI

We will be making this KPI:

Rolling 12 Months Sales

To calculate Rolling 12 Months Sales we require a calendar table because there is a requirement of creating a calendar table whenever we are dealing with dates in Power BI.

1.DAX for calendar table creation:

Calender = CALENDAR(MIN(Orders[Order Date]), MAX(Orders[Order Date]))

DAX for calendar table creation

where the arguments are the start and end dates in the main table which here is Orders and the MIN() and MAX() functions give us the min and max dates in Orders table which are nothing but our start and end dates.

Then this calendar table needs to be connected to the main table in data modelling section of Power BI. Just drag Date column in calendar table to the respective date column in main table. Refer this article for connecting the tables, it is very easy to do.

2.DAX for Rolling 12 Months Sales:

Rolling 12 Months Sales = CALCULATE(SUM(Orders[Sales]), DATESINPERIOD(Calender[Date], MAX(Calender[Date]), -12, MONTH))

DAX for Rolling 12 Months Sales

Here we are using CALCULATE function which requires an expression which is SUM(Orders[Sales]) and filter which is DATESINPERIOD.

Now DATESINPERIOD requires 4 parameters — Dates, Start Date, NumberOfIntervals and Interval.

  1. For Dates we use our calendar table which here is Calender, we use its Date column giving in total Calender[Date].
  2. For Start Date we are using the MAX date in our calendar table as that is the latest date in our table which in general is used in Rolling 12 Months calculations , also if your calendar table has dates up to the current/present date of creation of DAX then use TODAY(), in my case the calendar table had dates up to December 2022 so I used MAX(Calender[Date]).
  3. For NumberOfIntervals use -12 because we are going 12 months back from our Start Date.
  4. For Interval use MONTH because we going back month by month.

3.Formatting the KPI:

Now get a card(new) visual from Visualizations and put the Rolling 12 Months Sales to it. In Visualization head to Format your visual in Shape select Rounded Rectangle and set Rounded Corners to 10%.

Shape settings

Next head to Callout values, expand Values choose a colour of your choice, Bold the Font and for Horizontal alignment select Center.

Values settings

Next expand Label choose a colour of your liking, Bold the Font and in Position select Above Value.

Label settings

Next go to Cards, turn on Glow and expand it, select a colour of your choice, set Offset to Inside and Position to Right.

Glow settings

Next go to Cards, turn on Accent bar and expand it, select a colour of your choice, set Width to 10 px and Position to Bottom.

Accent bar settings

And finally we have our KPI

The Final KPI

To create a Concatenated KPI refer to this link.

To create a KPI with TopN refer to this link.

To create a KPI with an image refer to this link.

To read more stories like this you can follow me with this link.

References:

  1. https://www.investopedia.com/terms/k/kpi.asp
  2. https://www.forbes.com/advisor/business/what-is-a-kpi-definition-examples/
  3. https://en.wikipedia.org/wiki/Performance_indicator
  4. https://corporatefinanceinstitute.com/resources/valuation/last-twelve-months-ltm/

Don’t forget to subscribe to

👉 Power BI Publication

👉 Power BI Newsletter

and join our Power BI community

👉 Power BI Masterclass

--

--

Shashanka Shekhar
Microsoft Power BI

Contributor for Microsoft Power BI. I like Data Analysis and Data Science. Also I enjoy sports, videogames and Japanese Anime in my free time.