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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
yaman123
Post Patron
Post Patron

Week on Week Comparison using Week Start

Hi, 

 

I am looking to compare data on a week on week basis. I have a column in the date table which gives the start of each week on Monday - Sunday - 

Week Start Date(Mon-Sun) = 'Fiscal Calendar'[Date] - WEEKDAY('Fiscal Calendar'[Date],3)
 
I have measures in my tickets table which calculated tickets raised/ closed.  
 
Raised Tickets =

VAR maxSelectedDate = MAX('Fiscal Calendar'[Date])
VAR minSelectedDate = MIN('Fiscal Calendar'[Date])
RETURN
CALCULATE(COUNT('Table1'[Request Time Only]),'Table1'[Request Time Only] >= minSelectedDate && 'Table1'[Request Time Only] <= maxSelectedDate)
 
I am looking to do a weekly comparison of raised and closed tickets by category in a graph or so. I have a slicer which uses the Week Start date column so when i select a date, this should automatically calculate this week and last weeks data 
 
Thanks
 
 
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @yaman123 ,

 

I create a sample to have a test. 

Data model:

RicoZhou_0-1656570221130.png

Measure:

Raised Tickets = 
CALCULATE(COUNT(Table1[Request Time Only]))
Raised Tickets Last Week = 
VAR maxSelectedDate =
    MAX ( 'Fiscal Calendar'[Date] ) - 7
VAR minSelectedDate =
    MIN ( 'Fiscal Calendar'[Date] ) - 7
RETURN
    CALCULATE (
        COUNT ( 'Table1'[Request Time Only] ),
        FILTER (
            ALL ( Table1 ),
            'Table1'[Request Time Only] >= minSelectedDate
                && 'Table1'[Request Time Only] <= maxSelectedDate
        )
    )

Result is as below.

RicoZhou_1-1656570297828.png

RicoZhou_2-1656570311384.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @yaman123 ,

 

I create a sample to have a test. 

Data model:

RicoZhou_0-1656570221130.png

Measure:

Raised Tickets = 
CALCULATE(COUNT(Table1[Request Time Only]))
Raised Tickets Last Week = 
VAR maxSelectedDate =
    MAX ( 'Fiscal Calendar'[Date] ) - 7
VAR minSelectedDate =
    MIN ( 'Fiscal Calendar'[Date] ) - 7
RETURN
    CALCULATE (
        COUNT ( 'Table1'[Request Time Only] ),
        FILTER (
            ALL ( Table1 ),
            'Table1'[Request Time Only] >= minSelectedDate
                && 'Table1'[Request Time Only] <= maxSelectedDate
        )
    )

Result is as below.

RicoZhou_1-1656570297828.png

RicoZhou_2-1656570311384.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you! This is working fine!

amitchandak
Super User
Super User

@yaman123 , Based on what I got. Closed joined with date table having columns like

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1 //Monday week
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

 

example 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))

 

 

refer: https://medium.com/chandakamit/cheat-sheet-any-weekdays-week-start-date-just-one-variable-apart-6b2e...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors