Skip to main content

Power BI: Time Intelligence Rolling Measures

 One of the most powerful features of Power BI when it comes to DAX is a time series analysis.  Using pre-defined DAX functions can allow you to report on values based on specific time periods.  You can do things like referencing the previous year’s value, have a running year-to-date total, find closing balances for the month, and much much more.

 

For this blog, I want to explain how to get a rolling total for a specific time period.  Rather than just simply writing the expression, I am going to break it down step by step of how it is built out and why it works.  By understanding the reasoning behind the formulas, you can leverage this knowledge to apply time series analysis into your own Power BI reports.

 

For our rolling total, I will find the rolling sales amount for the last 3 months no matter what level of dates I am currently viewing in a visualization.  This calculation can be easily modified to finding a rolling total for the last 14 days, 2 quarters, or whatever you see fit.  You are also not limited to just doing totals, but any kind of mathematical aggregation is supported.

 

If you have not been introduced to using variables you will see them demonstrated here as an easier way to read and write your code.  Also, discussed in this calculation apart from the time series DAX functions, will be calculate, filter, and all.

 

Check it out below:

 

 


Comments

Popular posts from this blog

Pizza and DAX are my Love Languages

Okay, okay, not really. Beer is though. But if my wife asks, it's "quality time spent with her watching British dramas on PBS Masterpiece." In all seriousness, if you are new to Power BI - then DAX may seem like a foreign language.  Do you want to find out some quick tips or best practices?  Well, let me give you a few tips that were helpful to me when first starting to write DAX formulas. The TAB key is your best friend.   Don’t try to type everything character for character for your formulas.   Just type until you the formula, column, table, etc. shows up directly under the formula bar.   Once, it is there hit the tab button and it automatically promotes it into your formula bar.  Is the formula text too small for you?   It’s always too small for me when doing demonstrations for others.   Place your cursor in the formula bar.   Hold down the control key on your keyboard and use your mouse scroll wheel to make the text larger or smaller. Would you like to move to a new l

Loading Folders as Data Sources in POWER BI

  Power BI can connect to a plethora of different data sources.   Did you know Power BI can also make loading multiple files at one time a cinch?   There is an option from the Get Data icon for “Folder”.   Wait, a folder is not a data source, is it?   Well, all the files in that folder are for sure data sources. So what makes the “Folder” option something you need to know about?   Do you get new files with the same column structure sent to you on a set time frame and then have to go and append them to your existing file?   Have you ever found yourself appending multiple files over and over that have the same column structure?   If you answered yes to any of those last 2 questions, then you are going to fall in love with the “Folder” data source. Simply put, the “Folder” option allows you to bring in all of your files at once into Power BI.   You will then make all of your transforms on one sample file and Power BI will automate the process across all the files of your choosing and

Remove Duplicates And Keep Most Recent Records in Power BI

  A week ago in my last training, I was demonstrating how to get rid of duplicate records when making a dimension table.   One of the people in attendance asked is there a way to get rid of duplicates but keep the most recent duplicate record based on a date column.   I thought, “Of Course!”.   All we need to do is use the Query editor, do a sort on the date column, and then get rid of duplicates.   Unbeknownst to me, it didn’t work.   It kept the oldest record and not the newest.    The reason being after doing some research is that the Power Query editor will make determinations if it can do some of your steps in a different order and still give you the same result while producing the quickest data load.   Normally, that is what an ideal Power BI user wants, but in this case, we need the sort to happen before the remove duplicates step.   Thus, after research comes in the function Table.Buffer to modify our sort code.    Take a look at my video for a further explanation and demonstra