Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
THENNA_41
Post Partisan
Post Partisan

calculate duration Count between Opening stock and Consumption

i have table in  Out_duration . in tables three column  Month and  opening stock ,Consumation 

 

Month    opening stock           Consumation

Jan              10                             5

Feb              20                            2

Mar             10                             3

Apr              30                             8

May             10                            5

Jun               8                              6

July              10                            7

Aug              9                              5

Sep              8                               2 

Oct              1                               1 

Nov             1                               1

Dec             1                                1

 

Now i want to count  Consumation  equal to opening stock 

 

for Example  Jan Month Openingstock value  10  Consumation 5 less than to openingstock  

Refernce Screen shot : 

THENNA_41_0-1640335116166.png

Expected Output:

 

Month    opening stock           Consumation           Duration 

Jan              10                             5                             3

Feb              20                            2                              4

Mar             10                             3                             1

Apr              30                             8                             4

May             10                            5                               1

Jun               8                              6                              1

July              10                            7                               1

Aug              9                              5                               4

Sep              8                               2                               7

Oct              1                               1                               1

Nov             1                               1                               1

Dec             1                                1                               1

 

 

 

i have tire in Excel in the following formula

Duration = MATCH(B2,SUBTOTAL(9,OFFSET(C2,,,ROW(C2:$C$17)-ROW(C2))),1)-1

 

 

Looking for Help . thanks in advance 

 

 

2 REPLIES 2
THENNA_41
Post Partisan
Post Partisan

@amitchandak  let me try now sir 

amitchandak
Super User
Super User

@THENNA_41 , try to get month number or month rank an try these new column

 

Cumm New =
sumx(filter(table, [Month No] <= earlier( [Month No]) ), [Consumation])

 

Duration =
var _cumm = [Cumm New] + [opening stock]
var _Max = Minx(filter(Table, [Cumm New] >=_cumm ),[cumm])
return
maxx(filter(Table, [Cumm New] =_Max ),[Month No]) -[Month No]

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.