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
jayanthan
Helper III
Helper III

number of days zero stocks

Hi All

 

I wanted to identify number of days stockbalance has been zero,In the below example stockbalance has been zero from 16th Oct 2017 to 13th Jan 2018(89 days) for a specfic product in a given location

 

 

ProductIdLocationIDCustom_DateStockBalancestocktransaction
545199839852554210/16/201700
54519983985255421/13/201811
54519983985255424/12/201881748173
54519983985242285/14/20188484
54519983985243815/15/201888
54519983985245545/28/2018684684
54519983985242835/31/201822
54519983985243446/11/20181515
54519983985246226/12/20183434
54519983985243816/21/20186-2
54519983985246227/8/201831-3
54519983985243817/11/20184-2
54519983985255427/15/2018211-7963
54519983985243817/15/20182-2
54519983985246227/15/201830-1
54519983985246228/4/201829-1
54519983985246228/23/201827-2
54519983985250398/30/201811
545199839852462210/1/201825-2
545199839852434410/6/20189-6
545199839852455410/10/20186895
545199839852462210/10/20180-25
545199839852502710/10/201855

 

Jayanthan

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @jayanthan 

 

You may add an index column in query editor first and then create below measures.

NextDay =
IF (
    MAX ( Table1[StockBalance] ) = 0,
    CALCULATE (
        MAX ( Table1[Custom_Date] ),
        FILTER ( ALL ( Table1 ), Table1[Index] = MAX ( Table1[Index] ) + 1 )
    )
)
Date diff = DATEDIFF(MAX(Table1[Custom_Date]),[NextDay],DAY)

Regards,

Cherie

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 @jayanthan 

 

You may add an index column in query editor first and then create below measures.

NextDay =
IF (
    MAX ( Table1[StockBalance] ) = 0,
    CALCULATE (
        MAX ( Table1[Custom_Date] ),
        FILTER ( ALL ( Table1 ), Table1[Index] = MAX ( Table1[Index] ) + 1 )
    )
)
Date diff = DATEDIFF(MAX(Table1[Custom_Date]),[NextDay],DAY)

Regards,

Cherie

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.

Hi 

 

This is awesome, thanks for the support

 

 

Regards

Jayanthan

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.