Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

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

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@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
Not applicable

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

Anonymous
Not applicable

Hi @amitchandak,

 

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

Sofien1234_1-1650524743600.png

 

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.