Forum Discussion

user900's avatar
user900
Helper II
2 years ago
Solved

Help with Date

I have a data file that includes a Report Month field (10/1/2022 through 10/1/2023).  Data type is set as Date.  I want to create a measure to get the distinct count of IDs on or before 7/1/2023.  But when I do, it assumes 10/1/2023 is within that period.  Why and what do I need to fix it?

 

Thanks for any help.

 

  • Hi user900 
    Please try below measure

    Total Count= CALCULATE(COUNT('Table'[ID]),FILTER('Table','Table'[Date]<=DATE(2023,07,01)))

    If my post helps please give kudos and accept it as a solution!
    Thanks

5 Replies

    • user900's avatar
      user900
      Helper II

      Sample data:

      Report MonthID
      10/1/2022683
      11/1/2022683
      12/1/2022683
      1/1/2023683
      2/1/2023683
      3/1/2023683
      4/1/2023683
      5/1/2023683
      6/1/2023683
      7/1/2023683
      8/1/2023683
      9/1/2023683
      10/1/2023683
      10/1/2022160
      11/1/2022160
      12/1/2022160
      1/1/2023160
      2/1/2023160
      3/1/2023160
      4/1/2023160
      5/1/2023160
      6/1/2023160
      7/1/2023160
      8/1/2023160
      9/1/2023160
      10/1/2023160

       

      I'm expecting for the months Oct 2022 through July 2023 to have an outcome of 2.  The issue I have is it also returns 2 for Oct 2023 and shouldn't.

       

      My measure is: CALCULATE(DISTINCTCOUNT('Table'[ID]),'Table'[Report Month]<="7/1/2023")

      Report MonthExpected Outcome
      10/1/20222
      11/1/20222
      12/1/20222
      1/1/20232
      2/1/20232
      3/1/20232
      4/1/20232
      5/1/20232
      6/1/20232
      7/1/20232
      8/1/2023 
      9/1/2023 
      10/1/2023 
  • Uzi2019's avatar
    Uzi2019
    Community Champion

    Hi user900 
    Please try below measure

    Total Count= CALCULATE(COUNT('Table'[ID]),FILTER('Table','Table'[Date]<=DATE(2023,07,01)))

    If my post helps please give kudos and accept it as a solution!
    Thanks
    • user900's avatar
      user900
      Helper II

      Fantasic!  I did make a minor change.

      Total Count= CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[Date]<=DATE(2023,07,01)))

       

      Thank you so much.

  • Uzi2019's avatar
    Uzi2019
    Community Champion

    hi user900 

    can you do the following calculation:
    Total Count= CALCULATE(DISCTINCTCOUNT('Table'[ID]),FILTER('Table','Table'[Date]<=DATE(2023,07,01)))

     

    If my post helps please give kudos and accept it as a solution!
    Thanks