Forum Discussion

Irbaz's avatar
Irbaz
Frequent Visitor
4 years ago
Solved

Today() and Now() is not working for a DAX function

I have a table and I want to filter out the records which are due in 90 days, I used the following DAX query but now() and today() function is not working, I have tried both

Table 2 = Filter(
'Table',
DateDiff(
NOW(),
'Table'[Latest Date],
Day
) <=90
)

 

** How can I add a new column with values (overdue, due) on the basis of date.

 

Document TypeLatest Date
Certificate 13/1/2022
Certificate 21/31/2024
Layout Design7/1/2022
Statement 17/1/2022
Statement 23/1/2022
Processes Description10/1/2024
Flow Diagram10/1/2024
Floor Plan7/1/2022
Schedule 11/31/2024
Schedule 27/1/2022
List 17/1/2022
List 27/1/2022
Schedule A3/1/2022
Schedule Y3/1/2022
Schedule G3/1/2022
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Irbaz ,

     

    Try codes as below to create calculated columns.

    Overdue =
    VAR _DATEDIFF =
        DATEDIFF ( TODAY (), 'Table'[Latest Date], DAY )
    RETURN
        IF ( _DATEDIFF < 0, TRUE (), FALSE () )
    Due in 90 days = 
    VAR _DATEDIFF =
        DATEDIFF ( TODAY (), 'Table'[Latest Date], DAY )
    RETURN
        IF ( _DATEDIFF >= 0 && _DATEDIFF <= 90, TRUE (), FALSE () )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

     

     

3 Replies

  • Irbaz , try like

     

    Table 2 = Filter(
    'Table','Table'[Latest Date] >=Today() -90 && 'Table'[Latest Date] <=today())

     

    Now has time also, today is only date

  • Irbaz's avatar
    Irbaz
    Frequent Visitor

    amitchandak Thank you for your reply, 

    How can I create 2 columns ("overdue" and "due in 90 days") with values TRUE and FALSE, 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Irbaz ,

       

      Try codes as below to create calculated columns.

      Overdue =
      VAR _DATEDIFF =
          DATEDIFF ( TODAY (), 'Table'[Latest Date], DAY )
      RETURN
          IF ( _DATEDIFF < 0, TRUE (), FALSE () )
      Due in 90 days = 
      VAR _DATEDIFF =
          DATEDIFF ( TODAY (), 'Table'[Latest Date], DAY )
      RETURN
          IF ( _DATEDIFF >= 0 && _DATEDIFF <= 90, TRUE (), FALSE () )

      Result is as below.

       

      Best Regards,
      Rico Zhou

       

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