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
Rabz0912
New Member

Weekly on Week Sales Variance formular

Hi Guyz,

 

Please i need a dax formular for Week on Week Sales Varince. Any help will be so much appreciated 

2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@Rabz0912 

Make sure you have a dates table with a week number column

 

WeekOverWeek =
VAR LW =
    CALCULATE (
        SUM ( table[sales] ),
        FILTER (
            ALL ( 'dates' ),
            'dates'[weeknumber]
                = MIN ( 'dates'[weeknumber] ) - 1
        )
    )
RETURN
    SUM ( Append1[Video Views] ) - LW

 



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

v-luwang-msft
Community Support
Community Support

Hi @Rabz0912 ,

Since you did not provide specific data, I will use the following data as a template:

vluwangmsft_0-1627544649157.png

 

Step 1,create date table :

date = CALENDAR("2021,1,1","2021,12,31")

use the below to create new column:

weeknum = WEEKNUM('date'[Date]) 

vluwangmsft_1-1627544833372.png

 

And if you want weeknum start from  2021.1.1,use the below:

weeknum = IF( WEEKNUM('date'[Date]-5) >20&&MONTH('date'[Date])=1,1,WEEKNUM('date'[Date]-5))

vluwangmsft_2-1627545019192.png

Step2 ,create relationship:

vluwangmsft_3-1627545062040.png

Sales Varince = 
CALCULATE (
    SUM ( 'Table'[sale] ),
    FILTER ( ALL ( 'date' ), 'date'[weeknum] = MAX ( 'date'[weeknum] ) )
)
    - CALCULATE (
        SUM ( 'Table'[sale] ),
        FILTER ( ALL ( 'date' ), 'date'[weeknum] = MAX ( 'date'[weeknum] ) - 1 )
    )

vluwangmsft_4-1627545446246.png

 

And the following article may be helpful for you!

Variances: YoY, monthly and weekly comparision etc

Wish it is hlepful for you!

 

 

Best Regards

Lucien

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @Rabz0912 ,

Since you did not provide specific data, I will use the following data as a template:

vluwangmsft_0-1627544649157.png

 

Step 1,create date table :

date = CALENDAR("2021,1,1","2021,12,31")

use the below to create new column:

weeknum = WEEKNUM('date'[Date]) 

vluwangmsft_1-1627544833372.png

 

And if you want weeknum start from  2021.1.1,use the below:

weeknum = IF( WEEKNUM('date'[Date]-5) >20&&MONTH('date'[Date])=1,1,WEEKNUM('date'[Date]-5))

vluwangmsft_2-1627545019192.png

Step2 ,create relationship:

vluwangmsft_3-1627545062040.png

Sales Varince = 
CALCULATE (
    SUM ( 'Table'[sale] ),
    FILTER ( ALL ( 'date' ), 'date'[weeknum] = MAX ( 'date'[weeknum] ) )
)
    - CALCULATE (
        SUM ( 'Table'[sale] ),
        FILTER ( ALL ( 'date' ), 'date'[weeknum] = MAX ( 'date'[weeknum] ) - 1 )
    )

vluwangmsft_4-1627545446246.png

 

And the following article may be helpful for you!

Variances: YoY, monthly and weekly comparision etc

Wish it is hlepful for you!

 

 

Best Regards

Lucien

Fowmy
Super User
Super User

@Rabz0912 

Make sure you have a dates table with a week number column

 

WeekOverWeek =
VAR LW =
    CALCULATE (
        SUM ( table[sales] ),
        FILTER (
            ALL ( 'dates' ),
            'dates'[weeknumber]
                = MIN ( 'dates'[weeknumber] ) - 1
        )
    )
RETURN
    SUM ( Append1[Video Views] ) - LW

 



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.