cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mike_Mace
Resolver I
Resolver I

Matrix subtraction stop at current week

Happy lockdowning Forum,

 

I have a matrix with info:

1. A list of 25 deliverables with random plan dates and random dates they were submitted

2. I created (head) columns by "starting-date" week. All random dates are grouped in those weeks

3. To measure the missed items i created measure

failed = SUM('plan date'[plan sum])-Sum('submission date'[sub sum])
 
Notice on snip that subtraction takes place on all weeks, including future ones. 
I need subtraction to stop at week before current.
I thought about having an if on subsum >0 but that hasnt worked  (measure failed 2 on pbi file)
Ideas?
 
Snip:
 
1st.JPG

1 ACCEPTED SOLUTION

Sorry, I fooled myself.

failed 2 = 
SUMX (
    VALUES ( 'Date Calendar'[Week start] ),
    IF (
        'Date Calendar'[Week start]
            < TODAY () - WEEKDAY ( TODAY (), 2 ) + 1,
        CALCULATE(SUM ( 'plan date'[plan sum] ) - SUM ( 'submission date'[sub sum] )),
        BLANK ()
    )
)

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website


View solution in original post

6 REPLIES 6
mwegener
Super User
Super User

Hi @Mike_Mace ,

 

try this

 

failed = 
IF(MAX('Date Calendar'[Week start]) < TODAY()  - WEEKDAY(TODAY(),2) +1,
SUM('plan date'[plan sum])-Sum('submission date'[sub sum]), BLANK())
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website


Hi @mwegener 

 

That works well, it stops subtraction before running week thanks. 

Although it doesnt give Grand Totals for this measure. Any idea why? (named "failed 2" on snip below)

 

Mike_Mace_0-1612342639066.png

 

Hi @Mike_Mace ,

because the total does not filter to the start of the week.

Try this. 

failed =
SUMX (
    VALUES ( 'Date Calendar'[Week start] ),
    IF (
        MAX ( 'Date Calendar'[Week start] )
            < TODAY () - WEEKDAY ( TODAY (), 2 ) + 1,
        SUM ( 'plan date'[plan sum] ) - SUM ( 'submission date'[sub sum] ),
        BLANK ()
    )
)

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website


Hi @mwegener 

It looks like new "failed 3" has same results as "failed 2". I gave them a different highlight on the snip to read with ease. Still no row/grand totals
Is there a way around this or do i need to rethink model structure?

 

Mike_Mace_0-1612348654574.png

 

Sorry, I fooled myself.

failed 2 = 
SUMX (
    VALUES ( 'Date Calendar'[Week start] ),
    IF (
        'Date Calendar'[Week start]
            < TODAY () - WEEKDAY ( TODAY (), 2 ) + 1,
        CALCULATE(SUM ( 'plan date'[plan sum] ) - SUM ( 'submission date'[sub sum] )),
        BLANK ()
    )
)

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener work at KUMAVISION AG , one of the world's largest
implementation partners for Microsoft Dynamics. #
"Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website


@mwegener 

Works like a charm!

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors