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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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