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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Mikey_B
New Member

Dynamic date slicer

Hello! First time poster:

I am trying to make a date slicer, but I want the date to be dynamic, depending on another piece of information (earliest villain date):

Mikey_B_0-1727797243547.png


I want to have a graph on the report view that gives each Identifying number as a choice

When you click on that, I have measures to show how many "Run in with cops" before and after the "Earliest villain date"

What I want to do now, is be able to add a slicer based on their "Villain date" to zoom in on the month, 6 months and year surrounding their "Villain date".

Each villain date is unique to the ID, some don't have an earliest villain date at all (so they would not appear on the graph on the report view)

Is there a way to add a slicer/button to show 1month/6 months/1 year before and after their Earliest villain date?

(I hope that makes sense, please let me know how I can clarify)

1 ACCEPTED SOLUTION
AllisonKennedy
Community Champion
Community Champion

Okay, see attached file for a solution: 

 

 

Add a Custom Column to your data table using Power Query > Add Column > Custom Column

Duration.Days( [Run in with Cops] - [Earliest Villain Date])

 

Then create a new measure: 

Run in is within Selected Time Period = 
VAR _DaysWithin = SELECTEDVALUE( 'Time Slicer'[Days] )
VAR _Result = COUNTROWS( FILTER( 'Table', ABS('Table'[Days Since Earliest Villain Date]) <= _DaysWithin) )
RETURN
IF( MAX( 'Table'[Days Since Earliest Villain Date] ) = BLANK(), BLANK(), _Result )

 

AllisonKennedy_0-1727821835529.png

 

AllisonKennedy_1-1727821845780.png

 

 

I also added a date table for good practice, but you don't need it yet here: https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

 

 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.  Based on a villain data selected, show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AllisonKennedy
Community Champion
Community Champion

Okay, see attached file for a solution: 

 

 

Add a Custom Column to your data table using Power Query > Add Column > Custom Column

Duration.Days( [Run in with Cops] - [Earliest Villain Date])

 

Then create a new measure: 

Run in is within Selected Time Period = 
VAR _DaysWithin = SELECTEDVALUE( 'Time Slicer'[Days] )
VAR _Result = COUNTROWS( FILTER( 'Table', ABS('Table'[Days Since Earliest Villain Date]) <= _DaysWithin) )
RETURN
IF( MAX( 'Table'[Days Since Earliest Villain Date] ) = BLANK(), BLANK(), _Result )

 

AllisonKennedy_0-1727821835529.png

 

AllisonKennedy_1-1727821845780.png

 

 

I also added a date table for good practice, but you don't need it yet here: https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

 

 

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Community Champion
Community Champion

@Mikey_B  I'm working on a response for you - in future if you can paste the sample data in tabular format, for example:

 

 

Identifying number  Name Earliest Villain Date Run in with Cops
54701 Big Bad Wolf 7/26/2024 5/01/2024
10 Three Bears 5/02/2024 5/02/2024
2024 Darth Vader   5/11/2024
24246 Jafar   5/12/2024
54701 Big Bad Wolf 7/26/2024 6/05/2024
10 Three Bears 5/02/2024 6/10/2024
54701 Big Bad Wolf 7/26/2024 6/11/2024
54701 Big Bad Wolf 7/26/2024 6/15/2024
24246 Jafar   6/16/2024
64844 Ursela 6/16/2024 6/16/2024
1492 Pete   6/21/2024
24246 Jafar   7/01/2024
54701 Big Bad Wolf 7/26/2024 7/26/2024
10 Three Bears 5/02/2024 5/02/2024
2024 Darth Vader   8/11/2024
24246 Jafar   8/12/2024
54701 Big Bad Wolf 7/26/2024 8/12/2024
10 Three Bears 5/02/2024 8/14/2024
54701 Big Bad Wolf 7/26/2024 8/15/2024
54701 Big Bad Wolf 7/26/2024 8/18/2024
24246 Jafar   8/19/204
64844 Ursela 6/16/2024 8/19/2024
1492 Pete   8/19/2024
24246 Jafar   8/20/2024
54701 Big Bad Wolf 7/26/2024 8/20/2024
10 Three Bears 5/02/2024 8/21/2024
2024 Darth Vader   8/21/2024
24246 Jafar   8/22/2024
54701 Big Bad Wolf 7/26/2024

8/22/2024

 

It makes it much easier for us to support you in a way that's super easy for you to implement.

 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.