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

Every Sunday INV value

Hi,

 

I need to calculate Weeks of Inventory. Which logic is (last Sunday value)/avg(last 4 Sunday's value)

Could you please help me to get last Sunday's value? My data is the date-level granularity and I need to consider only every Sunday values.

 

as in the below image, I need to calculate (189118738- last Sunday)/avg(last 4 Sundays value highlighted)

 

tulasi_pbi1988_0-1615170538101.png

 

1 REPLY 1
amitchandak
Super User
Super User

@tulasi_pbi1988 , The way I will approch, Create Date table, Create sunday week start date

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],1)

Create Rank on week start date

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)

 

Last Sunday Week =CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank]) && 'Date'[Date] = 'Date'[Week Start date]))

 

Last 4 week =
CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-5 && 'Date'[Week Rank]<=max('Date'[Week Rank])-1 && 'Date'[Date] = 'Date'[Week Start date]))

 

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

 

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.