cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ashrin Regular Visitor
Regular Visitor

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

Accepted Solutions
Moderator v-yuezhe-msft
Moderator

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

@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
Moderator v-yuezhe-msft
Moderator

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

@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

ashrin Regular Visitor
Regular Visitor

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

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.

Moderator v-yuezhe-msft
Moderator

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

@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
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 272 members 2,914 guests
Please welcome our newest community members: