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
Ayyappa5678
Helper III
Helper III

DAX with Today (text data type), Last 7 dates(with text data type) and future dates(date data type)?

Hi Team,

I am new to power bi.

Kindly please help me below dax issue with date dropdown filter.

Like, Today date with Text Data Type

         Last 7 days with Text Data Type

          and Future dates with Date Data Type.

Kindly please he me on this case. I need to go all above cases in one dropdown filter. please help me best approch? 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Ayyappa5678 ,

I created some data:

Are you referring to the selection of the slicer to display the corresponding date.

Table1:

vyangliumsft_0-1694577536845.png

Table2:

vyangliumsft_1-1694577536847.png

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Table'[Slicer])
var _today=TODAY()
return
SWITCH(
    TRUE(),
    _select="Today"&&MAX('Table 2'[Date])=_today,1,
    _select="Last 7 dates"&&MAX('Table 2'[Date])>=_today-7&&MAX('Table 2'[Date])<_today,1,
    _select="future dates"&&MAX('Table 2'[Date])>_today,1,0)

 2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1694577577146.png

3. Result:

vyangliumsft_3-1694577577148.png

 

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @Ayyappa5678 ,

I created some data:

Are you referring to the selection of the slicer to display the corresponding date.

Table1:

vyangliumsft_0-1694577536845.png

Table2:

vyangliumsft_1-1694577536847.png

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _select=SELECTEDVALUE('Table'[Slicer])
var _today=TODAY()
return
SWITCH(
    TRUE(),
    _select="Today"&&MAX('Table 2'[Date])=_today,1,
    _select="Last 7 dates"&&MAX('Table 2'[Date])>=_today-7&&MAX('Table 2'[Date])<_today,1,
    _select="future dates"&&MAX('Table 2'[Date])>_today,1,0)

 2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_2-1694577577146.png

3. Result:

vyangliumsft_3-1694577577148.png

 

 

Best Regards,

Liu Yang

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

Ashok507
Frequent Visitor

I think it can be achieved using

"detect data type" option in" transform" tab of "power query editor"me.

No it is not working we will go with dax commands.
please suggest with DAX command!

Helpful resources

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