Forum Discussion

gregmhoffmann's avatar
gregmhoffmann
Frequent Visitor
7 years ago
Solved

Expense Forecasting From Static Excel Sheet

Hey Everyone!   I have an Excel workbook that has a list of expenses, what day of the week they are due, and the frequency of the expense in months (shown below)     Is there a way to crea...
  • LivioLanzo's avatar
    7 years ago

    Hello gregmhoffmann

     

    Please check if this query does what you want

     

     

    Table =
    SELECTCOLUMNS (
        GENERATE (
            Expenses,
            VAR __DayofMonth = Expenses[Due Date (Day of Mo)]
            VAR __StartDate = Expenses[Start Due Date]
            VAR __Frequency = Expenses[Frequency (in Mo)]
            VAR SameMonthDueDate =
                DATE ( YEAR ( __StartDate ), MONTH ( __StartDate ), __DayofMonth )
            VAR NextMonthDueDate =
                EDATE ( SameMonthDueDate, 1 )
            VAR FirstDueDate =
                IF ( SameMonthDueDate <= __StartDate, NextMonthDueDate, SameMonthDueDate )
            VAR NumberOfPeriods =
                ROUNDUP (
                    DATEDIFF ( __StartDate, EDATE ( TODAY (), 12 ), MONTH ) / __Frequency,
                    0
                )
            RETURN
                ADDCOLUMNS (
                    GENERATESERIES ( 1, NumberOfPeriods ),
                    "Test", EDATE ( FirstDueDate, ( [Value] - 1 ) * __Frequency )
                )
        ),
        "Expense", [Expense],
        "Payment Amount", [Payment Amount],
        "Date", [Test]
    )