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
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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

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.