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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
N_R_000
Helper I
Helper I

DAX Dynamic Date Table based on Selection

I need to build a dynamic date table which holds dates for the pevious 3 calendar months based on a month selected by a slicer. 

 

So if the user selects June 2021, I need to build a list of dates from 1st March 2021 - 31st May 2021

N_R_000_0-1623851822704.png

 

I've been using this to test the theory, which returns the dates I need:

Dim3Months = DATESINPERIOD(dim_Date[Date], DATE(2021, 03, 01), 3, MONTH)
 
but I can't get the correct syntax to replace the DATE(2021, 03, 01) part. If I use the slicer selected date [Report Run Date] shown in blue below, the date table starts at 1900 
 
N_R_000_1-1623852071338.png

 

Any pointers on what I can do to overcome?  

 

 

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @N_R_000 

 

Download the attached pbix file to see whether this meets your need.

062309.jpg

 

Since you want the slicer to filter the dates in previous 3 months, the dates for the table and for the slicer should come from different disconnected tables so that they won't filter each other based on the relationship.

 

Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.

N_R_000
Helper I
Helper I

Can anyone shed any light on this one? 

aj1973
Community Champion
Community Champion

Hi @N_R_000 

Can you share a sample of your file?

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Unfortunately, I can't as it's work related. But thi sproblem only affects one table (dim_Date) which contains every date from 1901 to 2099 (imported from data warehouse)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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