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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
bobbyd
Frequent Visitor

Comparing partial week to last year partial week when number of days in week are different

I'm stuck on how to figure this out.

 

I have a slicer for fiscal week end date and a table that displays for each week end date the week days and then compares to last fiscal year week.  Each fiscal week end date is always a Saturday.

So for week ending 9/2/2023, the days are Friday 9/1/2023 to Saturday 9/2/2023.  The last fiscal year week is Thursday 9/1/2022 to Saturday 9/3/2022.

 

So, my table ends up only showing Friday and Saturday because my slicer selection is week end 9/2/2023, which only contains 2 days.   Last year Thursday 9/1/2022 is only included the computed total line.  I have the correct calculations to get last fiscal week numbers, but the "Thursday" row, I can't figure out how to get to display.

 

I'm wanting to basically always show all 7 days on the table, with blanks where appropriate.    I've tried a disconnected table for the 7 days in a week, but could not figure out how to get the calculation for total sales to work for each day of the disconnected table.

 

This is only an issue when the first week of fiscal year is a partial week or last week of fiscal year is a partial week.

 

Need some pointers on how to do this.

 

Bob

 

 

1 ACCEPTED SOLUTION

Thanks.  It wasn't the exact solution for me, but it helped me get to my solution.

Thanks,

Bob

View solution in original post

2 REPLIES 2
Sahir_Maharaj
Super User
Super User

Hello @bobbyd,

 

Can you please try the following approach:

 

1. Create a Disconnected Table for the Days of the Week

DaysOfWeek = 
DATATABLE(
    "Day", STRING,
    {
        {"Sunday"},
        {"Monday"},
        {"Tuesday"},
        {"Wednesday"},
        {"Thursday"},
        {"Friday"},
        {"Saturday"}
    }
)

2. Create a measure to calculate the total sales for each day

TotalSalesByDay = 
VAR SelectedEndDate = SELECTEDVALUE('Calendar'[Fiscal Week End Date])
VAR SelectedStartDate = SelectedEndDate - 6
VAR SalesForDay = 
    CALCULATE(
        SUM('Sales'[Amount]),
        FILTER(
            'Calendar',
            'Calendar'[Date] >= SelectedStartDate &&
            'Calendar'[Date] <= SelectedEndDate &&
            'Calendar'[DayName] = SELECTEDVALUE(DaysOfWeek[Day])
        )
    )
RETURN
    SalesForDay

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Thanks.  It wasn't the exact solution for me, but it helped me get to my solution.

Thanks,

Bob

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.