Forum Discussion

TomM_5's avatar
TomM_5
Frequent Visitor
1 year ago
Solved

Measure For Last Invoice Date by Customer?

I have been asked to provide the last order date for each customer in a Power BI report. I am connecting to an existing semantic model, so I am unable to edit the model in Power Query or add a calcul...
  • johnt75's avatar
    1 year ago

    You can use LOOKUPVALUE

    lastInvoiceDate =
    VAR _dates =
        ALLSELECTED ( factSales[invoiceDateKey] )
    VAR _MaxDate =
        CALCULATE (
            MAX ( factSales[invoiceDateKey] ),
            REMOVEFILTERS ( factSales ),
            VALUES ( factSales[shippingCustomerKey] ),
            _dates
        )
    VAR _result =
        LOOKUPVALUE ( dimCalendar[calendarDate], dimCalendar[dateKey], _MaxDate )
    RETURN
        _result