Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Finding Historical Data

Hi All,    I have a dataset similar to the below.   ID On Hire Date Off Hire Date 1     2 01/01/2021 30/01/2021 3 01/02/2021   4 01/03/2021 10/03/2021 5 01/04/2021 2...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Please try:

    On Hire based on today = CALCULATE(COUNTROWS('Table'),FILTER('Table',[On Hire Date]<>BLANK()&&  [On Hire Date]<=TODAY() && [Off Hire Date]=BLANK()))

     

    If you want to calculate the count based on some selections, please firstly create a new calendar table with Dates for slicer

    Calendar = CALENDAR(MIN('Table'[On Hire Date]), MAX('Table'[Off Hire Date]))
    On Hire at certain time = CALCULATE(COUNTROWS('Table'),FILTER('Table',[On Hire Date]<>BLANK()&&  [On Hire Date]<=MAX('Calendar'[Date]) && ([Off Hire Date]=BLANK()|| [Off Hire Date]>=MAX('Calendar'[Date]))))

     

    On Hire over selected perioid = CALCULATE(COUNTROWS('Table'),FILTER('Table',[On Hire Date]<>BLANK() && [On Hire Date]<=MIN('Calendar'[Date]) && ( [Off Hire Date]>=MAX('Calendar'[Date]) || [Off Hire Date]=BLANK())))

     

     Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.