Forum Discussion

harshagraj's avatar
harshagraj
Icon for Post Partisan rankPost Partisan
4 years ago
Solved

Filter projects between the Start and End Date

Hello all,

 

I have a start and end date for a project. And i am visualizing this on Road map custom app.

I need to create a slicer/parameter. If user inputs/selects 2019(Start date),2022(End date) then i need to filter projects which starts and end between 2019&2022 and also projects which are passing this year.

Project NumberStart DateEnd Date
PRJ-08-0000008408-05-201817-02-2022
PRJ-09-0000002608-01-201913-05-2021
PRJ-08-0000009606-05-202109-03-2023
PRJ-21-0009037620-05-202122-12-2022
PRJ-21-0009041320-05-202130-11-2023
PRJ-08-0000009510-05-202211-05-2023

amitchandak  please help.

 

6 Replies

  • harshagraj if user are entering the year , and not selecting from a date table, change the measure:

     

    Started in range =
    //you don't need minx and maxx, these are iterators
    var _max = DATE ( [ParameterStartYearValue], 1, 1 )
    var _min  =DATE ( [ParameterEndYearValue], 12, 31 )
    return
    
    calculate(count(Table[Project Number]), 
    //no need to use filter iterator
    //Filter(Table,
    Table[StartDate] <=_max,
    Table[StartDate]) >=_min
    )

     

    ✨ Follow us on LinkedIn

     

    Learn about conditional formatting at Microsoft Reactor

    My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) 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.⚡

  • harshagraj I guess this is what you need:

     

    Started in range = 
    var _min = DATE ( [StartYearValue], 1, 1 )
    var _max = DATE ( [EndYearValue], 12, 31 )
    return
    calculate ( 
        count ( Projects[Project Number] ), 
        (
            Projects[Start Date] >= _min && 
            Projects[Start Date] <=_max
        ) 
        ||
        (
            Projects[End Date] >=_min &&
            Projects[End Date] <=_max
        )
    )

     

    ✨ Follow us on LinkedIn

     

    Learn about conditional formatting at Microsoft Reactor

    My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) 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.⚡

  • harshagraj , If you have date table joined with Start date that should do. Only count(Table[Project Numer])  is needed

     

    But

    With help from and independent date table
    Started in range =
    var _max = minx(allselected(Date), Date[Date])
    var _min = maxx(allselected(Date), Date[Date])
    return
    calculate(count(Table[Project Number]), Filter(Table,(Table[StartDate] <=_max && Table[StartDate]) >=_min) )


    Started in range and end after Range =
    var _max = minx(allselected(Date), Date[Date])
    var _min = maxx(allselected(Date), Date[Date])
    return
    calculate(count(Table[Project Number]), Filter(Table,(Table[StartDate] <=_max && Table[StartDate]) >=_min && Table[EndDate] >_max) )

     

    Also check how you work with both start and end date. You can avoid any active join

     

    https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

  • amitchandak few improvement on your DAX:

     

    Started in range =
    //you don't need minx and maxx, these are iterators
    var _max = MIN ( Date[Date] ) // minx(allselected(Date), Date[Date])
    var _min = MAX ( Date[Date] ) //maxx(allselected(Date), Date[Date])
    return
    
    calculate(count(Table[Project Number]), 
    //no need to use filter iterator
    //Filter(Table,
    Table[StartDate] <=_max,
    Table[StartDate]) >=_min
    )

     

    ✨ Follow us on LinkedIn

     

    Learn about conditional formatting at Microsoft Reactor

    My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) 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.⚡

    • harshagraj's avatar
      harshagraj
      Icon for Post Partisan rankPost Partisan

      Hello parry2k  amitchandak  thanks for the quick answers but i am confused.
      I have created two paramaters Start Date & End Date and user will input the required year. But from the calculation you provided i am not able to understand. 

    • harshagraj's avatar
      harshagraj
      Icon for Post Partisan rankPost Partisan

      Hello parry2k please see the image. If Parameter start and end date is 2019 and 2021 i need Projects starting from 2019 and ends in 2021 and also which are passing in between these dates.
      Eg: PRJ-08-00000084 Year(Start date) is 2018 but it is passing in 2019 also becaue the year(end date) is 2022.