Forum Discussion

chris_m's avatar
chris_m
Icon for Helper I rankHelper I
9 years ago
Solved

Weekly Variance between snapshots / time periods

I'm trying to replace an old excel report with a better version using Power BI, but I am having trouble creating a measure that will replicate the results of the old report.    I have two time dime...
  • v-chuncz-msft's avatar
    v-chuncz-msft
    9 years ago

    chris_m,

     

    You may refer to the following DAX that creates a new table.

    Table =
    ADDCOLUMNS (
        ADDCOLUMNS (
            SUMMARIZE (
                Sheet1,
                Sheet1[CPS WEEK],
                Sheet1[Pack Week],
                "Sum of Containers", SUM ( Sheet1[No. of containers] )
            ),
            "Prev", SUMX (
                FILTER (
                    Sheet1,
                    Sheet1[CPS WEEK]
                        = EARLIER ( Sheet1[CPS WEEK] ) - 1
                        && Sheet1[Pack Week] = EARLIER ( Sheet1[Pack Week] )
                ),
                Sheet1[No. of containers]
            )
        ),
        "Variance", IF ( ISBLANK ( [Prev] ), BLANK (), [Sum of Containers] - [Prev] )
    )