Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Days Between Last Date and Today

I have a data set with where items have multiple ship dates, I need to calculate the number of weeks between the last shipped date (most recent date) and today. I have tried datediff, creating custom...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Looks like "lastDate" is a reserved name.  We just need to change the variable name to something else.  Try this:

    Shipped Days Ago = var itemNumber = SELECTEDVALUE('YourTable'[ITEM_NUMBER])
    var lastDateVal = CALCULATE(
        MAX('YourTable'[SHIPPED_DATE]),
        ALL('YourTable'),
        'YourTable'[ITEM_NUMBER] = itemNumber
    )
    RETURN
    DATEDIFF(Today(), lastDateVal, DAY)