Future-Proof Your Career, Master Data Skills + AI

Blog

Blog

# Showing Month to Date (MTD) To Current Date In Power BI Using DAX

by | 9:00 am EST | March 07, 2020 | Business Intelligence, DAX, Power BI

Showing month-to-date calculations to the current date (i.e. today) in Power BI is a common problem that I see all the time. The same goes with quarter- t- date and year-to-date. I’ve been asked this on the Enterprise DNA Support Forum quite a lot so it’s timely to create a tutorial around how to solve it. You may watch the full video of this tutorial at the bottom of this blog.

In this tutorial, I’m going to show how you can solve this quite easily using DAX formulas.

Many times when you showcase time comparison information, you want to show some results versus the previous month or the same month the previous year.

Historical information is usually projected for the entire month. The problem comes in when you might be in the middle of the month and you only want to show up to the current date.

So I’m going to show you how you can show the true like for like comparison. To illustrate this, I’m going to work with 20 days into the current quarter. In this example, we’re comparing to the first 20 days of the quarter last year.

## Time Comparison Using DAX

I’ve already got a few measures here so now we’re going to create quickly the quarter to date number. To do this, we click on New Measure and then write the formula in the formula bar.

We name this formula Sales QTD, and then use Time Intelligence functions. Using these functions are not too difficult. It’s just a matter of understanding which one to use. In this case, we are using the CALCULATE function.

We then grab it and put it inside the table, and we’ll see the results.

We can also put this into a chart, and we see that this is showing a quarter to date number. We use the date slicer as well and quickly change the time frame.

So for instance, we’re now in quarter 4 and we’re only going to have information up to the last twenty days because in this example it’s the 20th of October. To show that, we need to get our previous year’s numbers. First, we need to work out the previous year sales.

In this formula, we use the DATEADD, which is another Time Intelligence function. We’re comparing to the previous year, so we need to jump back a year here.

Since we wanted to go from sales previous year to sales previous year quarter to date, we simply need to replace the Total Sales inside our Sales QTD formula to previous year (Sales PY) to get our Sales PY QTD.

After which we drag it into our table and we can see the comparison of sales quarter to date (QTD) in the current context versus the prior year.

Now I’m going to show you what you probably have if you’re looking at live data. I’ll use this formula for our Total Sales to demonstrate it.

With IF logic, this is probably what you see in your data. You have sales quarter-to-date or it could be month-to-date or year-to-date, and then you’re looking at the entire number for the previous year.

We want to highlight only a certain period, so we need to implement some logic to enable us to do that.

## Showcasing True Time Comparisons

To show the true Power BI month-to-date, quarter-to-date, or year-to-date time comparisons, we need to get rid of or blank out the numbers that are past today or where they sit in the current context.

In the table below, we see that this is exactly today, 20th of October. We need to blank out this number if it’s greater than this date.

All we have to do is jump to our Sales PY QTD and wrap some IF logic around it like so.

This logic is saying, “if the last date is greater than today then make that equal to blank; if not then equal to the result”, and that’s going to do the work.

We see also the changes in the chart because the chart will not return blank values.

What’s great about this calculation is that it’s live, so as we go through time, the TODAY field is going to update and will give us the additional date or days worth of data every day.

## Conclusion

In this article, I take you through the exact steps to follow and some of the DAX formulas that you need to implement to show true Power BI month-to date, quarter-to-date, or year-to-date time comparisons. I used quarter to date (QTD) in the demonstration.

I ran through how you can effectively change your visualizations to illustrate the information in your Power BI reports in a compelling way. There’s plenty to learn around DAX formula visualization techniques.

With this blog tutorial, you will understand how to effectively manage time intelligence or time comparison-type information really well in all your Power BI reports.

All the best with this.

Sam

## Power BI Bookmarks: The Ultimate Guide

When working with data, bookmarks offer a streamlined and personalized way to navigate through large...

## Power BI Default Slicer Value Explained

One of the key features of Power BI is the slicer, which allows you to filter your data based on...

## Power BI Copilot: Enhancing Data Analysis with AI Integration

Are you ready to elevate your data analysis capabilities? Then let's delve into the realm of Power BI...

## What is Microsoft Fabric? A Guide to Features & Benefits

Imagine a one-stop shop that not only crunches numbers like it's eating cereal for breakfast but also...

## Python AttributeError: ‘dict’ object has no attribute Fix

Python is widely appreciated for its readability and ease of understanding. Among its numerous...

## Power BI vs Tableau: Differences Compared 2023

In the world of data visualization and analytics, two industry-leading data visualization tools stand...

## Pandas Drop Index Column: Explained With Examples

Pandas is a widely used Python library for data manipulation and analysis. One essential functionality...

## Microsoft DP-500 Explained (Bonus Cheat Sheet)

Data is the backbone of businesses these days, and having proof that you know how to handle and make...

## Power BI Financial Dashboard Examples: Let’s Get Specific

Power BI financial dashboards provide a quick and easy way to monitor an organization's financial...

## Power BI Themes: User Guide With Examples

Power BI is a powerful business analytics tool that helps you visualize and analyze data from various...

## Power BI Hierarchy: User Guide With Examples

Imagine being able to look at your data from every which way â€” from the bird's eye view right down to...