Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Find Nearest Date in a Calendar

I've a data base, for Invoices paid on the last few months. I've Invoice Date, Invoice Creation Date, Invoice Due Date and Invoice Payment Date. In other table I've a calendar with Dates based on a c...
  • tamerj1's avatar
    tamerj1
    3 years ago

    Hi Anonymous 
    Please find attached sample file containing both options.

    Cycle Date 2 = 
    MAXX (
        TOPN (
            1,
            FILTER (
                'Calendar',
                'Calendar'[Month Number] = MONTH ( PaidInvoices[Due Date] )
                    && PaidInvoices[Due Date] - 'Calendar'[Date] >= 0
            ),
            PaidInvoices[Due Date] - 'Calendar'[Date],
            ASC
        ),
        'Calendar'[Date]
    )