Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculate previousweek performance starting monday

Hi,

 

Yesterday I calculated the previousmonth on a calculation which works, but I am struggling to find how you can calculate last weeks performance. With last week performance I want to calculate it starting Monday till Sunday. So for example when opening the report on a Thursday I don't want to see the performance from the last 7 days till Thursday, but simply the last week from Monday till Friday.  Below is the calculation for previousmonth, how should I adjust it that it calculates the previous weeks performance?

 

 

Previous Month = 
CALCULATE(
    DIVIDE(
        CALCULATE(
            DISTINCTCOUNT ('KPI  42&43'[ULD No.]),
            'KPI  42&43'[On time/not on time] = "On Time"
        ),
        ( DISTINCTCOUNT ('KPI  42&43'[ULD No.]))
    ),
    PREVIOUSMONTH ('date'[Date].[Date])
)+0

 

 

Thanks in advance.

 

Kind regards,

 

Sofiën

3 Replies

  • Anonymous , new columns in date table

     

    new columns
    Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
    Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
    Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
    OR
    Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

     

    new  measures
    This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
    Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
    Last year Week= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
    Last 8 weeks = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-8 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

     

    Power BI — Week on Week and WTD
    https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
    https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
    https://www.youtube.com/watch?v=pnAesWxYgJ8

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak,

       

      I did find your old thread containing WTD setup. Everything went fine except for the WTD measure itself.

       

      I excluded the SUM expression because the value should not summarize. Instead I added another measure I created  'Gross/Net'[Gross P-to-D]. This measure is as followed:

       

      Gross P-to-D = CALCULATE(DISTINCTCOUNT('KPI 42&43'[ULD No.]),'KPI 42&43'[Gross/net] = "Gross").
       
      Dont immediately see where the issue is.
       
      Kind Regards,
       
      Sofiën
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak, it does work now. Had to change somethign in the datetable. Thanks!