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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
mic_user
Frequent Visitor

How to create 1 slicer to do filtering based on the values of 2 date type columns? (Start/End Date)

I'm new to Power BI and would really appreciate any input on this.

 

By taking the table below as an example.

 

mic_user_1-1742781108473.png

 

 

 

I'm looking to create a slicer and let's call it "Project Year" and it should return all the related projects (e.g. by selecting 2022 in the slicer, we should get project A and B because project B started in 2021 and ended in 2024, hence 2022 and 2023 (the years in between) are considered as its project years too).

 

Would like to highlight that there are projects with only start date or end date being entered, and also projects without any date being entered yet. By selecting 2022 in the slicer, would also like to include those with only start date/end date being entered as 2022

 

Can refer to more examples below.

 

mic_user_2-1742781750592.png

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @mic_user 

You can handle this with a variation on the Events in Progress pattern. Take a look at the # Open Orders ALL measure for example.

 

I have attached a small PBIX illustrating how I would set it up.

 

1. Given how you need to handle blank Start Date or End Date values, I recommend adding columns to the Projects table with this pseudocode (I added these in Power Query):

  • Start Date Effective = COALESCE ( Start Date, End Date )
  • End Date Effective = COALESCE ( End Date, Start Date)

2. In my example I assume that the 'Date' table has no relationship with the Projects table. If there is a relationship, see comments in code below.

3. Create these measures:

# Projects = 
COUNTROWS ( Projects )
# Projects in Progress = 
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Result =
    IF (
        NOT ISFILTERED ( 'Date' ),
        [# Projects],
        CALCULATE (
            [# Projects],
            Projects[Start Date Effective] <= MaxDate,
            Projects[End Date Effective] >= MinDate
            -- If there is a relationship between Date -> Projects,
            -- then add an argument: REMOVEFILTERS ( 'Date' )
        )
    )
RETURN
    Result

3. Create a visual grouped by Project, with visual-level filter "# Projects in Progress is not blank":

OwenAuger_0-1742786734046.png

4. Filters on 'Date' columns such as 'Date'[Year] then filter this visual as expected:

OwenAuger_1-1742786795087.png

Does something like this work for you?

 

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar question in the attached file.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
OwenAuger
Super User
Super User

Hi @mic_user 

You can handle this with a variation on the Events in Progress pattern. Take a look at the # Open Orders ALL measure for example.

 

I have attached a small PBIX illustrating how I would set it up.

 

1. Given how you need to handle blank Start Date or End Date values, I recommend adding columns to the Projects table with this pseudocode (I added these in Power Query):

  • Start Date Effective = COALESCE ( Start Date, End Date )
  • End Date Effective = COALESCE ( End Date, Start Date)

2. In my example I assume that the 'Date' table has no relationship with the Projects table. If there is a relationship, see comments in code below.

3. Create these measures:

# Projects = 
COUNTROWS ( Projects )
# Projects in Progress = 
VAR MinDate =
    MIN ( 'Date'[Date] )
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Result =
    IF (
        NOT ISFILTERED ( 'Date' ),
        [# Projects],
        CALCULATE (
            [# Projects],
            Projects[Start Date Effective] <= MaxDate,
            Projects[End Date Effective] >= MinDate
            -- If there is a relationship between Date -> Projects,
            -- then add an argument: REMOVEFILTERS ( 'Date' )
        )
    )
RETURN
    Result

3. Create a visual grouped by Project, with visual-level filter "# Projects in Progress is not blank":

OwenAuger_0-1742786734046.png

4. Filters on 'Date' columns such as 'Date'[Year] then filter this visual as expected:

OwenAuger_1-1742786795087.png

Does something like this work for you?

 

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Thanks @OwenAuger , this works for me!

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors