0
votes

In PowerBI, I have a standard date dimension, except one of the columns tells me if the date is a part of the "Current Week" or "Last Week". It looks something like this:

 Date           CurrentLast
5/15/2017       
5/16/2017        
5/17/2017       Last Week
5/18/2017       Last Week
5/19/2017       Last Week
5/20/2017       Last Week
5/21/2017       Last Week
5/22/2017       Last Week
5/23/2017       Last Week
5/24/2017       Current Week
5/25/2017       Current Week
5/26/2017       Current Week
5/27/2017       Current Week
5/28/2017       Current Week
5/29/2017       Current Week
5/30/2017       Current Week

What I am trying to do is create a cumulative total for the Current Week and for Last Week. Standard DAX formulas seem to yield only cumulative for the two-week period

Cumulative Total = 
CALCULATE(
    [Sum Of Col1],
    FILTER( 
        ALLSELECTED('Date'),
        'Date'[Date] <= max( 'Date'[Date] )
    )
)

Will yield something like this:

enter image description here

but as you can see, the "Current Week" line is a continuation from the "Last Week" line, but I want the "Current Week" line to start at 0 (or rather whatever the value is on Tuesday and not Last Week + Tuesday)

Anyone know how to get this line to start at the correct value?

2

2 Answers

1
votes

Not sure if I understand you correctly, but can't you solve it by creating two measures; one for Last Week, and one for Current Week and add both to the graph?

0
votes

That's basically what I did, I created two measures that sum for each week and then used the quick measures feature to generate the code. HEre's what it spit out.

Previous Week Cumulative = 
CALCULATE(
    [LastWeek],
    FILTER(
        CALCULATETABLE(
            SUMMARIZE('Date', 'Date'[WeekDayNumber], 'Date'[WeekDay]),
            ALLSELECTED('Date')
        ),
        ISONORAFTER(
            'Date'[WeekDayNumber], MAX('Date'[WeekDayNumber]), DESC,
            'Date'[WeekDay], MAX('Date'[WeekDay]), DESC
        )
    )
)