Default Your Slicer to the Current Month in Power BI

Default Your Slicer to the Current Month in Power BI

First Published November 2022 on our YouTube Channel

Join 65,000+ subscribers to stay up to date with new videos release every week.


Is it possible to default your slicer to the current month? No.

But wait..you can..and here's a breakdown on how to do just that.

Watch the video or read on below:

The End Result

No alt text provided for this image

Let's start by looking at the end result. We have a month slicer that displays an option for the current month. This feature can be especially handy when you want to keep your data up to date, whether you're manually refreshing it or have it set to auto-refresh.?


Once the data is refreshed, the slicer will automatically update to show the new current month, ensuring that you're always viewing the most recent data.


Adjusting Your Power Query Calendar

The magic behind this is a special calendar table built in Power Query, equipped with handy columns such as 'Months since today', 'Weeks since current month', and a few others.

You can set up this calendar so that whenever the 'Months since today' column hits zero (which signifies the current month), it outputs the word 'Current'. This is done using a simple conditional formula.?

You can download the file and take a look at the code here

No alt text provided for this image


The table also has a 'Sort by' column, which helps to ensure that 'Current' is always the first option in your slicer.



Understanding "Current"

Before you proceed, it's important to clarify what you mean by 'current month'.?

Are you referring to 'today' as the current date every time you refresh your data, or do you mean the latest transaction date as 'current'? Depending on your definition, you might need to adjust your calendar table slightly.


For instance, if you're going by the actual current date, you can set up your calendar table to reflect this using Date.From(DateTime.LocalNow() ).

Alternatively, if you're referring to the latest transaction date, you can use the 'List.Max' function to retrieve the maximum date from your Fact table.


Sort by Column

Remember that for this slicer to work as intended, you need to make sure the 'Sort by' column is properly set up in your slicer. This is the column that determines the order of the options in your slicer and makes sure 'Current' shows up first.


Things to Keep in Mind

While this is a handy feature, there are a couple of things to keep in mind. Firstly, the 'current' month will actually be missing from your slicer, since it's being replaced by the 'Current' option. Secondly, if you want to switch years, you'll need to click off 'Current' before you can do so.


Conclusion

This is a feature I've been experimenting with and so far, it's proving to be quite useful. Let me know what you think in the comments! See you in the next video!

You can download the file and take a look at the code here


SideNote:

The crazy thing about this article is that I didn't write it. I copied the transcript from my YouTube vidoe and pasted into ChatGPT and used a prompt to write a blog post from a YouTube transcript. It then generated the content which I modified slightly and uploaded screen shots. It's pretty amazing. For more GPT4 content I have a YouTube playlist here:

Wyn

wyn.bio.link

No alt text provided for this image


Timo Riikonen

Data Analyst at Innofactor

1 年

Besides this solution and Mateusz Mossakowski, there is also a simple solution where you replace today's month, such as "Aug 2023" with value "Current month". Note: If you do the replacement in PowerQuery, then you should refresh data on morning to ensure that this works on the first day of the month. Benefits: Sorting works automatically correctly, there is only one single list of values so in this cases you just have "Current month" coming after July and before September where you would expect August.

Jahangir Jabbar

Al-Futtaim IKEA | xNoon | xSharaf | Accounting & Finance | Reporting | Analyst | ERP | BI | SQL

1 年

Thank you for sharing this. I've actually been trying to figure this out lately. Cheers ??

Mateusz Mossakowski

Husband | Dad | Business Intelligence Guy | IT Software Engineering Manager at Procter & Gamble

1 年

I would allow myself to share my proposal regarding default slicer selections in PBI :) https://medium.com/@mossakowski.mateusz/dynamic-default-slicer-value-in-power-bi-f02fbec4f481

要查看或添加评论,请登录

Wyn Hopkins的更多文章

  • The Best Dependent Drop Down Technique

    The Best Dependent Drop Down Technique

    Driven by a gauntlet laid down by friend and fellow MVP Mark Proctor on our Unpivot podcast recently I revisited my…

    1 条评论
  • Should you use Measures for Conditional Formatting?

    Should you use Measures for Conditional Formatting?

    Streamline Your Power BI Conditional Formatting with Measures I've always found the built-in conditional formatting in…

    6 条评论
  • Consolidate and Hyperlink to Excel files on SharePoint

    Consolidate and Hyperlink to Excel files on SharePoint

    In this video, we're diving into the world of Excel and Power BI, focusing on creating hyperlinks for easy referencing…

    4 条评论
  • The greatest multi-level Excel drop-down list ever!

    The greatest multi-level Excel drop-down list ever!

    One-Off dependent drop down lists in data validation are relatively straightforward: here's a technique using XLOOKUP…

    5 条评论
  • Power BI Licensing Explained

    Power BI Licensing Explained

    What are the differences between: Power BI Free (soon to be renamed Fabric Free) Pro: $10 USD pp/pm PPU (Premium Per…

    2 条评论
  • Power BI May 2023 Release

    Power BI May 2023 Release

    The May version of Power BI desktop is out This is a very quick post highlighting my 2 favourite picks: 1. Azure Maps…

    5 条评论
  • Simpler DAX ? = Power Query

    Simpler DAX ? = Power Query

    If you are struggling to write a complicated DAX formula then the answer may be to step back and do a little Power…

    2 条评论
  • Power BI Explained

    Power BI Explained

    A simple explanation of Power BI I hope you find this useful. Power BI continues to go from strength to strength and…

  • SUMX explained.

    SUMX explained.

    SUMX is a DAX function that can be used in an Excel Data Model (aka Power Pivot) to create a temporary column…

    6 条评论
  • XLOOKUP v Power Query v Power Pivot

    XLOOKUP v Power Query v Power Pivot

    When combining tables in Excel there are several options. In this video I show you XLOOKUP, Power Query Merge and a…

    5 条评论

社区洞察

其他会员也浏览了