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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Matt_Joers
New Member

Dynamically Format Date based on Slicer Selection

Greetings Team, I'm trying to figure out a way to dynamically format the date options in a Slicer based on another Slicer. In my example, here is how the dates should be formatted in the slicer:

 

- If a user selects "Daily" from the first slicer, the date options should display as "mmm dd yyyy".

- If a user selects "Prior Month" from the first slicer, the date options should display as "mm yyyy"

- If a user selects "Year To Date" from the first slicer, the date options should display as "mmm dd yyyy"

 

Below is a screenshot of the configuration currently - please let me know if anyone has any plausible ideas. Power BI Dates.PNG

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Matt_Joers 


Try to create a measure like this:

Format = 
SWITCH(
    SELECTEDVALUE(Slicer[Processing Interval]),
    "Daily",FORMAT(MAX('Table'[Date]),"mmm dd yyyy"),
    "Prior Month",FORMAT(MAX('Table'[Date]),"mm yyyy"),
    "Year To Date",FORMAT(MAX('Table'[Date]),"mmm dd yyyy")
    )

 
Result:

vangzhengmsft_1-1639371596183.png

If you only want to see the formatted date, you can change the column width of the service date column to 0.

 

Please refer to the attachment below for details. Hope this helps.

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Kbandewar
Frequent Visitor

This works when we want to just showcase the consolidation in dates, for example, here we have used MAX(date).
Is there any way to present all the dates and not just the MAX or MIN of date ?
I want to use date column on Y axis.
and as a slicer I have Annual, Monthly, Daily,
So if Annual is selected, all the dates should be YYYY
if monthly selected then, MM/YYYY and so on

Abandon that idea and use a date column and zoom sliders.

v-angzheng-msft
Community Support
Community Support

Hi, @Matt_Joers 


Try to create a measure like this:

Format = 
SWITCH(
    SELECTEDVALUE(Slicer[Processing Interval]),
    "Daily",FORMAT(MAX('Table'[Date]),"mmm dd yyyy"),
    "Prior Month",FORMAT(MAX('Table'[Date]),"mm yyyy"),
    "Year To Date",FORMAT(MAX('Table'[Date]),"mmm dd yyyy")
    )

 
Result:

vangzhengmsft_1-1639371596183.png

If you only want to see the formatted date, you can change the column width of the service date column to 0.

 

Please refer to the attachment below for details. Hope this helps.

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Keep in mind that a slicer can only be populated by values from a column, not from a measure.

 

So what you would need to do is to have ALL of your formatting options pre-computed in that "Service Date" column, and then have another column that indicates which of the "Processing Interval" options the value corresponds to.  This also mandates single value selection on your "Processing Interval" slicer, but you already have that.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors