Forum Discussion

LostinDaxland's avatar
LostinDaxland
Regular Visitor
2 years ago
Solved

DAX Help! Return Latest Date, but stop after finding first value

Hi - I'm really hoping that I can get some help here. I've been banging my head against the wall a while trying to figure this out. Please go easy on me - I'm very new to DAX (or any kind of coding.....
  • bhanu_gautam's avatar
    2 years ago

    LostinDaxland , Try using below DAX

     

    Latest Invoice =
    VAR maxDate =
    CALCULATE(
    MAX(Trial[Invoice Date]),
    ALLEXCEPT(Trial, Trial[Project Number])
    )
    VAR minInvoiceID =
    CALCULATE(
    MIN(Trial[Invoice ID]),
    ALLEXCEPT(Trial, Trial[Project Number]),
    Trial[Invoice Date] = maxDate
    )
    RETURN
    IF(
    Trial[Invoice Date] = maxDate && Trial[Invoice ID] = minInvoiceID,
    "Latest Invoice",
    BLANK()
    )