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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SeanPolley_Apty
Frequent Visitor

Week On Week - Sales and Opportunities from SF Report

Objective:
Show the week on week change for both Sales and Number of Opportunities from a Salesforce Report. This dummy set only includes 2023 dates but the real dataset is from the 2021-2023. Multiple years also presents another issue to work around.

Table:

Create Date (Date)Week of Year (Int)Opportunity Name (Text)Sales USD (Fixed Decimal)
01/01/231SF Company 1500
01/02/231SF Company 2300
01/03/231SF Company 3800
01/08/232SF Company 4200
01/09/232SF Company 5700
01/10/232SF Company 6500
01/16/233SF Company 7400
01/17/233SF Company 8100
01/18/233SF Company 9500
01/19/233SF Company 10700


Objective Results (Sales)

WeekSales This WeekSales Last WeekDelta
1$1,600 $1600
2$1,400$1,600$-200
3$1,700$1,400$300


Objective Results (Opportunity)

WeekOps This WeekOps Last WeekDelta
13 3
2330
3431



1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with a week number column.  Create a relationship (Many to One and Single) from the Date column of the Data table to the Date column of the Calendar table.  To your visual, drag Week number from the Calendar Table.  Write these measures

Total = sum(Data[Sales USD])

Total in previous week = calculate([Total],datesbetween('Calendar'[date],min('calendar'[date])-7,min('calendar'[date])-7)))

Variance = [Total]-[Total in previous week]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with a week number column.  Create a relationship (Many to One and Single) from the Date column of the Data table to the Date column of the Calendar table.  To your visual, drag Week number from the Calendar Table.  Write these measures

Total = sum(Data[Sales USD])

Total in previous week = calculate([Total],datesbetween('Calendar'[date],min('calendar'[date])-7,min('calendar'[date])-7)))

Variance = [Total]-[Total in previous week]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

Thanks for the reply, this seems to work with Week #. Is there a way I can modify this to work with the Week of Year intead of the Week Num. This would let me account for multiple years as it looks like Week Num is pulling from all years. I've tried modifying the Total Previous Week for Week of Year, however it's not returning correctly.


Week of Year.PNG

 

Total Previus Week of Year =
CALCULATE([Total],DATESBETWEEN('Calendar'[Week of Year],
MIN('Calendar'[Week of Year])-1, MIN('Calendar'[Week of Year])-1))


Thanks again!

You are welcome.  I do not understand.  What is the difference between week number and week of year?  Show the download link of the file and show the expected result very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That was a mistake on my end, Week of Year is correct you can ignore Week #.

Sample Dataset (One Year)
I was getting the correct values when I filtered down to just one year.

YearWeek of YearSales This WeekSales Last WeekDelta
20221$100 $100
20222$150$100$50
20223$50$150-$100

 

Sample Dataset (Multiple Years)
I believe the error was happening as it would calculate for Week of Year = 1 values including both 2022 and 2023.

YearWeek of YearSales This WeekSales Last WeekDelta
20221$100 $100
20222$150$100$50
20223$50$150-$100
20231$100 $100
20232$150$100$50
20233$50$150-$100


However, I found a work around by creating a Year & Week of Year column (YYYY-WW) to sort chronologically and using the following OFFSET formula. From there it was a simple measure between This Week and Last Week to get a weekly delta.

Sales_LastWeek =

CALCULATE(
    [Sales_ThisWeek],
    OFFSET(
        -1,
        ALLSELECTED('Data'[Year & Week]),
        ORDERBY('Data'[Year & Week], ASC)))

Thanks again for taking the time to help me out. Sometimes just talking about it with others helps me realize things I wouldn't have thought of by myself.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.