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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Creating a dynamic date filter for the current day

Hi!

 

I am having trouble with the date filter I have created. It is dynamically made with DAX commands to filter data according to the current date.

2022-03-09 (1).png

I have attached a sample power bi file of this filter. The issue I am having is I would like the filter to only show the data with dates that occur prior to and including the selected date. 

 

https://drive.google.com/file/d/1dJQOgVHnbxpcQ3QbJ3qdMbxajMPoWsHI/view?usp=sharing

 

Thank you for helping!!

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

Hi, @Anonymous ;

You could create a flag measure.

flag = 
var _max=CALCULATE(MAX('data'[date]),ALL('data'))
var _year= IF(MAX('FilterYear_Table'[Disp Year])="Today’s Year",YEAR(_max), CONVERT(MAX('FilterYear_Table'[Disp Year]),INTEGER))
var _month= IF(MAX('FilterMonth_Table'[Disp Month])="Today’s Month",MONTH(_max),MONTH(  MAX('FilterMonth_Table'[Disp Month]) & " 1"))
var _day= IF(MAX('FilterDay_Table'[Disp Day])="Today’s Day",DAY(_max),CONVERT(MAX('FilterDay_Table'[Disp Day]),INTEGER))
return IF(MAX([date])<=DATE(_year,_month,_day),1,0)

Then apply it into filter.

vyalanwumsft_0-1647228586474.png

The final output is shown below:

vyalanwumsft_1-1647228623046.png

Best Regards,
Community Support Team _ Yalan Wu
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

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create another measure.

count = COUNTROWS( SUMMARIZE(FILTER('data',[flag]=1),[date],[name]))

The final output is shown below:

vyalanwumsft_0-1647330836130.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a flag measure.

flag = 
var _max=CALCULATE(MAX('data'[date]),ALL('data'))
var _year= IF(MAX('FilterYear_Table'[Disp Year])="Today’s Year",YEAR(_max), CONVERT(MAX('FilterYear_Table'[Disp Year]),INTEGER))
var _month= IF(MAX('FilterMonth_Table'[Disp Month])="Today’s Month",MONTH(_max),MONTH(  MAX('FilterMonth_Table'[Disp Month]) & " 1"))
var _day= IF(MAX('FilterDay_Table'[Disp Day])="Today’s Day",DAY(_max),CONVERT(MAX('FilterDay_Table'[Disp Day]),INTEGER))
return IF(MAX([date])<=DATE(_year,_month,_day),1,0)

Then apply it into filter.

vyalanwumsft_0-1647228586474.png

The final output is shown below:

vyalanwumsft_1-1647228623046.png

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi,

Thank you for your help! I was wondering if how would you create a card that would display the total number of names displayed in the chart for the selected date? 

When I tried duplicating the chart and coverting the data into a card, the card only seems to display the overall total number of data values instead of the number of data values displayed.

 

Thank you!

Anonymous
Not applicable

I tried it with the power bi file, but the total only displays the overall total of the entire data set. I attached a copy of the file.

Thank you for your help!

 

https://drive.google.com/file/d/13fXAgCnV24fWR33fKVph7FqFHF56zOnb/view?usp=sharing

amitchandak
Super User
Super User

@Anonymous , You have create these in you table 

 

Year Type = Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)

 

Month Type = Switch( True(),
Eomonth([Date],0)= Eomonth(Today(),0),"This Month" ,
month([Date]) & "" // or// format([Date],"mmm")
)

 

 

Month Type = Switch( True(),
[Date]= Today(),"This Day" ,
Day([Date]) & ""
)

 

Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi! Thank you for your help! I was wondering if there was a way for me to also display all the data that falls on the dates leading up to the selected date as well?

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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