Forum Discussion

Francisco_G_Cal's avatar
4 years ago
Solved

Calculate difference between two dates in different tables not directly related

Hi I need to calculate the time elapsed between to dates, in days. The values are the creation date and the payment date for every invoice in my model table. I will use this value to classify my inv...
  • johnt75's avatar
    4 years ago

    You could try and create a calculated column on Invoices like

    Days elapsed in payment =
    VAR invoiceNo = Invoices[Invoice Number]
    VAR invoiceDate = Invoices[Invoice Date]
    VAR maxPaymentDate =
        CALCULATE (
            MAX ( Installments[InstallmentPaymentDate] ),
            Payments[Invoice Number] = invoiceNo
        )
    RETURN
        INT ( maxPaymentDate - invoiceDate )