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
Anonymous
Not applicable

Dax to find the OOS (Out of Stock) for consecutive Days

Hi Team,

 

Please find the following data.here how to find the Out of Stock for consecutive days.Here you can see Item 100 only having OOS for 3 consecutive days.So i need to get the answer 3.

 

DateItemOOS
10-06-20191001
11-06-2019150 
12-06-20191001
13-06-20191001
14-06-2019101 
15-06-2019102 
16-06-2019100 
17-06-20191021
18-06-2019102 
19-06-20191021
1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may create a rank column.Then create below measures to get the count.

Rank = RANKX(FILTER(Stock,Stock[Item]=EARLIER(Stock[Item])),Stock[Date],,ASC)
Next_oos = CALCULATE(MAX(Stock[OOS]),FILTER(ALL(Stock),Stock[Item]=MAX(Stock[Item])&&Stock[Rank]=MAX(Stock[Rank])+1))
Last_oos = CALCULATE(MAX(Stock[OOS]),FILTER(ALL(Stock),Stock[Item]=MAX(Stock[Item])&&Stock[Rank]=MAX(Stock[Rank])-1))
Count = COUNTROWS(FILTER(Stock,Stock[OOS]=1&&OR([Next_oos]=1,[Last_oos]=1)))

a1.png

Regards,

Community Support Team _ Cherie 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

2 REPLIES 2
v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may create a rank column.Then create below measures to get the count.

Rank = RANKX(FILTER(Stock,Stock[Item]=EARLIER(Stock[Item])),Stock[Date],,ASC)
Next_oos = CALCULATE(MAX(Stock[OOS]),FILTER(ALL(Stock),Stock[Item]=MAX(Stock[Item])&&Stock[Rank]=MAX(Stock[Rank])+1))
Last_oos = CALCULATE(MAX(Stock[OOS]),FILTER(ALL(Stock),Stock[Item]=MAX(Stock[Item])&&Stock[Rank]=MAX(Stock[Rank])-1))
Count = COUNTROWS(FILTER(Stock,Stock[OOS]=1&&OR([Next_oos]=1,[Last_oos]=1)))

a1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-cherch-msft 

 

Thank you for the reply 🙂 Its really help full.

 

One more thing,can you suggest me to visualise the following requirement.

 

I need to showcase how many items are OOS for 1 Day,2 Day 3 day etc

 

Days1D2D3D
Item Count120

 

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.