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
ckhoo2007
Helper I
Helper I

Calcuate Weekly difference and create a table

Hi,

I am new to Power BI, I have the following data:

ckhoo2007_0-1623813803457.png

 

I would like to create a table calculating the % difference on weekly basis for sales per client, something like below:

ckhoo2007_1-1623813844685.png

 

Appreciate your help how to create the Measure, many thanks.

 

br,

Choo

1 ACCEPTED SOLUTION

Thanks Amit.

But I already have week number in the table, can't I just sum up e.g. for the same client and same week then divide by the sum of previous week?

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ckhoo2007 , with a date table and Week rank you can do that

 

Examples

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
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

 

measures
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

 

Diff % = divide([This week] -[Last Week], [Last Week])

 

 

refer my blogs for more details

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8

Thanks Amit.

But I already have week number in the table, can't I just sum up e.g. for the same client and same week then divide by the sum of previous week?

Hi Amit,

I tried to create the measures and they worked, thanks.

 

Br,

Choo

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.