Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JRA21_13_19_25
Frequent Visitor

Dynamic Date Slicer including a Week and Quarter option

Hello,

 

I want to create a dynamic date slicer in power BI that would allow the x axis of my bar chart to dynamically change so my end-users can have the option to breakdown the figures Yearly, Quarterly, Monthly, Weekly or Daily. 

 

I have managed to create a slicer for Daily, Monthly and Yearly using the DAX formula below but I’m struggling with adding the Weekly and Quarterly DAX.

 

To create the dynamic slicer, I have created a table using the following DAX formula:

 

Dynamic Date Selection =

UNION(

    ADDCOLUMNS(

        CALENDAR(MIN('Date Table'[Date]),MAX('Date Table'[Date])),

        "Visual Date",FORMAT([Date],"dd-mmm-yyyy"),

        "Type", "Daily",

        "Type Order",1,

        "Visual Date Order", FORMAT([Date],"yyyy-mm-dd")

    ),

    ADDCOLUMNS(

        CALENDAR(MIN('Date Table'[Date]),MAX('Date Table'[Date])),

        "Visual Date",FORMAT([Date],"MMM yyyy"),

        "Type", "Monthly",

        "Type Order",2,

        "Visual Date Order", FORMAT([Date],"yyyy-mm")

    ),

       ADDCOLUMNS(

        CALENDAR(MIN('Date Table'[Date]),MAX('Date Table'[Date])),

        "Visual Date",FORMAT([Date],"yyyy"),

        "Type", "Yearly",

        "Type Order",3,

        "Visual Date Order", FORMAT([Date],"yyyy")

    )

)

 

Dynamic Date Selection Table: 

JRA21_13_19_25_2-1642364595003.png

 

Below is a pic of what I have created so far: 

JRA21_13_19_25_1-1642364429192.png

Please can anyone help me with the Week and Quarter DAX? 

 

Many thanks

 

1 ACCEPTED SOLUTION

I see, 

The basic structure in ADDCOLUMNS for yearly and monthly is to have a date in theire respective formats to have this for quarter and week is similar to having them in calendar. 

E.g.

    ADDCOLUMNS(

        CALENDAR(MIN('Date Table'[Date]),MAX('Date Table'[Date])),

        "Visual Date",

CONCATENATE(YEAR([Date])& "/",QUARTER([Date]))

,

        "Type", "Quarter",

        "Type Order",2,

        "Visual Date Order",

CONCATENATE(YEAR([Date])& "/",QUARTER([Date]))

    ),

 

For week you can use WEEKNUM.


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hey Hi , Did You Got the Solution For this Query ? Im Also got Strucked with these In Weekly And hourly Basis

If You Know Can you suggest me How can i change dynamically in  weekly and Hourly

ValtteriN
Super User
Super User

Hi,

I recommend watching this video from BI Elite about the topic:
https://www.youtube.com/watch?v=hilfglpKNRQ







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ValtteriN ,

 

Yes thanks this is where I got the DAX for the Day, Month and Year but he doesn't explain how to do it for Week and Quarter. Any ideas how? 

 

Thanks

I see, 

The basic structure in ADDCOLUMNS for yearly and monthly is to have a date in theire respective formats to have this for quarter and week is similar to having them in calendar. 

E.g.

    ADDCOLUMNS(

        CALENDAR(MIN('Date Table'[Date]),MAX('Date Table'[Date])),

        "Visual Date",

CONCATENATE(YEAR([Date])& "/",QUARTER([Date]))

,

        "Type", "Quarter",

        "Type Order",2,

        "Visual Date Order",

CONCATENATE(YEAR([Date])& "/",QUARTER([Date]))

    ),

 

For week you can use WEEKNUM.


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Great thank-you @ValtteriN 

 

Do you think the week would also work with week commencing instead of week number ?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.