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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dcrow5378
Helper III
Helper III

Date Slicer Default to first day of month and Max data date

Hello,

I have a date slicer that I would like to set to the first day of the month and the latest data date.

The latest data date is always yesterday.

If I set the filter to "is in this month" then on the first day of the following month the data dates do not display correctly.

 

So basically on 4/1/21, the date range should be 3/01/21 - 03/31/21.

On 4/2/21 the date range should be 4/1/21 - 4/1/21.

On 4/3/21 the date range should be 4/1/21 - 4/2/21.

 

This works fine all month until the month changes then I have issues.

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

Hi @dcrow5378 

According to your date, create two measures to return the date you want firstly .

The latest data date = SELECTEDVALUE('Table'[Date])-1

The first day of the month = EOMONTH('Table'[The latest data date],-1)+1

Ailsa-msft_0-1619399796067.png

Then use the two measures as  the start time and end time of the time period .

  

Best Regards

Community Support Team _ Ailsa Tao

 

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
v-yetao1-msft
Community Support
Community Support

Hi @dcrow5378 

According to your date, create two measures to return the date you want firstly .

The latest data date = SELECTEDVALUE('Table'[Date])-1

The first day of the month = EOMONTH('Table'[The latest data date],-1)+1

Ailsa-msft_0-1619399796067.png

Then use the two measures as  the start time and end time of the time period .

  

Best Regards

Community Support Team _ Ailsa Tao

 

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

Thanks @v-yetao1-msft

I used this with the following to filter my Date Range Slicer:

 
DateRange =
VAR MaxDt = MAX(DateDim[Date])
VAR FirstDt = EOMONTH(MaxDt,-1)+1
RETURN

IF(DateDim[Date] >= FirstDt && DateDim[Date] <= MaxDt, TRUE(),FALSE())
AllisonKennedy
Super User
Super User

@dcrow5378  The only way I can think to solve this would be to create a custom column in Power Query and set the date filter on that custom column? Basically shift the [Date] column so that the filter shows the dates you want when you want them? 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

So basically I need a formula for max date in table and the first day of the max dates month.
Then apply the filter for if the date falls in this range. 

Helpful resources

Announcements
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.