Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Why Datesinperiod returns future date

Hello everyone,

I have a question. When I use the Datesinperiod function, it always returns the future dates, is there any way to eliminate them? 

Here is my code 

CAPAs Opened MTD Measure = CALCULATE(COUNT('CAPAs Opened MTD'[CAPA PR ID]),
    DATESINPERIOD('Date Table'[Date],LASTDATE('Date Table'[Date]), -1, MONTH))
 
Thanks for helping me
  • johnt75's avatar
    johnt75
    3 years ago

    You could try DATESBETWEEN('Date'[Date], MAX('Fact  table'[Date]), TODAY())

3 Replies

  • A properly formed date table will have dates until 31 December in the final year, which could be why you're getting dates in the future. If you want to restrict it to 1 month from today you could use DATESINPERIOD('Date'[Date], TODAY(), -1, MONTH)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi johnt75

      I can not use Today(), because I need to include all the previous dates. My ideal result is from last date of my data to today.  Is that possible?

       

      • johnt75's avatar
        johnt75
        Icon for Super User rankSuper User

        You could try DATESBETWEEN('Date'[Date], MAX('Fact  table'[Date]), TODAY())