Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Showing latest date before specific date

Hi all   I am trying only to show the client's latest ticket date if it's older than two weeks using DAX.   For example, today is the 21st and 2 weeks ago it was the 7th, I only want to show the ...
  • bolfri's avatar
    bolfri
    3 years ago

    Thank you for sample data. Here is the code:

    Customers with last ticket older than 2 weeks ago = 
    var customer_last_ticket =
        MAXX(
            DISTINCT('Sample'[client_id]);
            MAX('Sample'[created_at])
        )
    return IF(DATEDIFF(customer_last_ticket;TODAY();DAY)>=14;customer_last_ticket)

    In the variable customer_last_ticket we are storing an information about last ticket per customer

    Then if this ticket is older than 14 days ago we are displaying int 🙂

     

    I hope that this is what you've wanted.