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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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)

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
Super User
Super User

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
Super User
Super User

@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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.