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

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

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors