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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ashrin
Helper I
Helper I

Dynamic date slicer that can be used in a calculated Dax column

I currently have a Slicer that has 3 options : Active, Inactive and Future. These option come from a calculated column like this :

IF startdate <= TODAY() && enddate >= TODAY(), "Active",

IF enddate < TODAY(), "Termed",

IF start_date > TODAY(), "Future"

 

I need to create a slicer that will let me select a date and based on that date, it should give me Active, Inactive, Future instead of just having TODAY(). is this possible ? 

Im using imported date from MSSQL

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@ashrin,

"I need to create a slicer that will let me select a date and based on that date, it should give me Active, Inactive, Future instead of just having TODAY(). is this possible ? "

Create a calendar table using dax below.

calendar = CALENDAR("1/1/2016","12/30/2018")


Create a measure in your original table.

checkdate = IF(MAX(Table[startdate] )<= MAX('calendar'[Date]) &&MAX( Table[enddate] )>=MAX('calendar'[Date]), "Active", IF(MAX(Table[enddate]) < MAX('calendar'[Date]), "Termed",IF( MAX(Table[startdate] )> MAX('calendar'[Date]), "Future")))


Create date slicer using date field of calendar table.
1.PNG

Regards,
Lydia

Community Support Team _ Lydia Zhang
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-yuezhe-msft
Employee
Employee

@ashrin,

"I need to create a slicer that will let me select a date and based on that date, it should give me Active, Inactive, Future instead of just having TODAY(). is this possible ? "

Create a calendar table using dax below.

calendar = CALENDAR("1/1/2016","12/30/2018")


Create a measure in your original table.

checkdate = IF(MAX(Table[startdate] )<= MAX('calendar'[Date]) &&MAX( Table[enddate] )>=MAX('calendar'[Date]), "Active", IF(MAX(Table[enddate]) < MAX('calendar'[Date]), "Termed",IF( MAX(Table[startdate] )> MAX('calendar'[Date]), "Future")))


Create date slicer using date field of calendar table.
1.PNG

Regards,
Lydia

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

Thanks so much. 

 what Im trying to do is :

We have a list of people who are either active, termed or future active. these people all have a start date and an end date. i have a slicer where i can select "Active", "termed", "Future". when i click on active, all the people who are active today show up. when i click termed, all who were active before today and not active anymore will show up, if the start date is greater than today, then future active records will show up. 

Now, all these options are relative to todays date. I want to do this based on a date other than today(future or past). So when i select a date, the active, termed and future records show up based on the date i select not not today.

I would like this date to be a single select date and not a range.

 

Basically your solution works, to an extent. I also need a slicer that would let me select active, termed and future.

@ashrin

It is not possible to drag a measure to slicer, you can drag the measure into visual level filter and then set different values.

Based on my understanding, you check the user status by creating a calculated column containing active, inactive and so on, however, in this case, calculated column can't be changed dynamically based on slicer selection(date slicer in your scenario), please review this KB to get details.

Regards,
Lydia

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.