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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

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

@Anonymous 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

@Anonymous 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

@Anonymous 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.

Anonymous
Not applicable

@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

@Anonymous 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.

Anonymous
Not applicable

@parry2k  awesome! thank you very much!

Anonymous
Not applicable

@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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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