Power BI Dynamically Filtering Dates

One problem which forced me to pause for thought recently was how to dynamically filter data in Power BI. Eg: Filtering data by a date range to only show sales for the last 7 days.

I believe the two simplest options are using either the Q&A natural query language or using Power BI Desktop’s built in Date/Time filter options found in the query editor, both of which have been documented below.

Option 1 – Using the Power BI web app

Using the Q&A text box of your dashboard you can simply ask in “natural language” to see your data from the last 7 days, as shown in the screenshot below.  This can then be pinned to the dashboard if it is a question you are going to ask on regular basis.

This does take a little bit of tweaking to get the desired results as you are relying on the Power BI engine to understand your query.

image

Fortunately if no results are found Power BI does give you some suggestions should it not be able to find useful answers to your question, as shown in the screenshot below.

image

Option 2 – Using the Power BI Desktop app

When you import data using Power BI Desktop you are greeted with the Query Editor, from here you can click the drop down arrow for the date column in question. Next select Date/Time Filters and you will be exposed to a number of filtering options unavailable in the reports or dashboard tabs, From here I have selected “In the Previous”.

image

Once you have selected your filter (eg: In the Previous) all you need to do is set how many days you want to count back.  In this instance the result of this filter means that I am only going to see data in my reports where the Created Date is in the previous 7 days.

image

The Microsoft Power BI team have already included a few useful built in filters, such as the Year To Date filter shown in the screenshot below.

image

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s