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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

week over week measures giving two very different results

Hello Community  -  I am trying to diagnose why the results of these two different 'week over week' formulas are so different.  

 

In the first measure (which I know is correct) I am using a fully qualified column reference.    In the second formula, I am using a sumx measure.    You can see in my table that a change from 38 units returned in Week 33  to  52 units returned in Week 34, is indeed  a 36.84% change.  

 

Just trying to figure out what is wrong with that 2nd formula as I'd like to make use of the VAR functions.  

 

 

week over week .jpg

 

Week over Week Qty Change =
VAR lastWeekAmount =
CALCULATE (
SUM ( Merge1[Qty To Return] ),
FILTER (
ALL ( 'Date Table' ),
'Date Table'[Week Number]
= MIN ( 'Date Table'[Week Number] ) - 1
)
)
RETURN
DIVIDE ( SUM ( Merge1[Qty To Return] ) - lastWeekAmount, lastWeekAmount, 0 )

 

-----

 

Week over Week2 =
VAR CurrentWeek = SELECTEDVALUE('Date Table'[Week Number])
VAR CurrentYear = SELECTEDVALUE('Date Table'[Year])
VAR MaxWeekNumber = CALCULATE(MAX('Date Table'[Week Number]), ALL('Date Table'))
RETURN
SUMX(FILTER(ALL('Date Table'),
IF(CurrentWeek = 1,'Date Table'[Week Number]=MaxWeekNumber && 'Date Table'[Year]=CurrentYear - 1,'Date Table'[Week Number]=CurrentWeek - 1 && 'Date Table'[Year]=CurrentYear)),[SumX Qty to Return])
1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have modified your second formula . Please refer to my .pbix file.

v-lionel-msft_0-1599112233059.pngv-lionel-msft_1-1599112252707.png

 

Best regards,
Lionel Chen

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

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have modified your second formula . Please refer to my .pbix file.

v-lionel-msft_0-1599112233059.pngv-lionel-msft_1-1599112252707.png

 

Best regards,
Lionel Chen

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

amitchandak
Super User
Super User
Anonymous
Not applicable

@amitchandak    Hi Amit  -  I am not totally clear on your question.  

 

But if I do not have a year filter....so instead use a relative date  (past 30 days for example), I still get the same issue.   One formula works and one does not.  

@Anonymous , in the first formula you are using week number only. Same week number can be there across the year.  So I doubt that answer will match with one formula use year.

 

Check if my Rank approach can help you.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.