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
IEG
Frequent Visitor

To find when stock amount of an item turns to positive from negative

Hi,

 

I have a stock projection file, it predicts the stock amount of items in each week considering open orders, usage etc. 

I need to find when stock amount of an item turns to positive from negative. In the below example we will have a supply gap of 147 pcs in week 29, however in the following week (week30) because of incoming products we will have an excess of 1604 items. So I need to create a measure which calculates week 30 

IEG_0-1657723192956.png

 

Thanks

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@IEG , One of the Idea I have is to create measure This week vs last week and check

 

if( [Last Week] >0 && then [This Week] <0 , 1, blank())

 

For this week vs last week

You need week rank in a separate date/week table

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

and then create measures like
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

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

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Create a couple of measures like

Negative to Positive =
var currentValue = [Volume]
var prevValue = CALCULATE([Volume], DATEADD('Date'[Date], -7, DAY))
return IF( prevValue < 0 && currentValue > 0, 1)

Week turns positive = FIRSTNONBLANK('Date'[Week no 2], [Negative to Positive])
amitchandak
Super User
Super User

@IEG , One of the Idea I have is to create measure This week vs last week and check

 

if( [Last Week] >0 && then [This Week] <0 , 1, blank())

 

For this week vs last week

You need week rank in a separate date/week table

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

and then create measures like
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

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.