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
VV24
Helper III
Helper III

Active year slicer within start and enddate

Dear all,

I have a table as following:

IDStart dateEnd date
A15-2-201815-6-2025
B1-1-20201-1-2024
C26-2-202131-12-2021

 

I would like to have a slicer on my report with a year and then show the selected IDs where the year is in (and in between) the start and end date. Example with results:

I filter 2019, this would only give me ID 'A' because that is the only ID where A is active.

I filter 2021, I returns all three, cause all three are taking place in this year.

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@VV24 solution attached, you can tweak as per your need.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@VV24 here is the updated measure and in visual level filter change where a value greater than equal to 1

 

In the future, do create a separate post and do refer back to the original post, doesn't matter if it is an extension of existing question:

 

Filter Id = 
VAR __result = 
SUMX (  
    VALUES ( 'Table'[ID] ), 
    VAR __selectedYear = SELECTEDVALUE ( Years[Year], YEAR ( TODAY() ) )
    VAR __minBuildDate = YEAR ( CALCULATE ( MIN ( 'Table'[Start date] ) ) )
    VAR __maxBuildDate = YEAR ( CALCULATE ( MIN ( 'Table'[End date] ) ) )
    RETURN
    IF ( __selectedYear >= __minBuildDate && __selectedYear <= __maxBuildDate, 1, 0 ) 
)
RETURN __result

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@VV24 not fully sure what you are looking for, maybe open another post and refer back to this so that these stay as a separate solution.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k well it is actually the same dataset and case. with the following results in a cardvisual

I filter 2019, this would only give me ID 'A' because that is the only ID where A is active. so the count would be 1 (the result).

I filter 2021, I returns all three, cause all three are taking place in this year. which gives me 3 as a result.

2024 returns 2 and so on.

parry2k
Super User
Super User

@VV24 solution attached, you can tweak as per your need.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  awesome! thank you very much!

@parry2k  can you also make this work when you want to distinctcount the IDs in a card visual? you cant use the measure as a filter like in a table then.

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.