Solved

# How to calculate weeks of supply

• 10 replies
• 204 views

Userlevel 5
+1
• Semi-Pro II
• 220 replies

Does anyone have a good way to calculate the weeks of supply based on the current available inventory? I’m trying to add this to a GI and my thought was to base it on the qty sold over the past 60 days; taking that qty divided by 8.57 (the approximate # of weeks that are in 60 days) would give me the qty sold per week. Then I’d need to divide the qty available by the qty sold per week to get the # of weeks supply. But I can’t figure out how to make that work in a formula.

icon

Best answer by mikeho 29 November 2022, 20:48

View original

### 10 replies

Userlevel 7
+4

@mikeho Have you checked into using the INSiteStatus table to check for Qty Available and INTran or SOTran to find the qty sold and then make your calculations based off these?

If you make a condition on the GI to look for @Today - 60 based on tran dates then it should keep a running calculation based on the current date.

Does this sound like what you’re trying to build?

Userlevel 5
+1

Hi @BenjaminCrisman  - yes, I’m using both of those tables. I can obtain the qty sold over the past 60 days from the INTran table and the qty available from the INSiteStatus table; what I’m struggling with is the formula to turn those data points into calculating the # of weeks of supply based on the current qty available. Looking for assistance there.

Userlevel 7
+12

Hi @mikeho

Attaching GI which is developed to see the movement of Qty on hand and sold on a weekly basis

Also, you can search with a data filter range. It may help you

Userlevel 5
+1

Thank you for the GI you provided; unfortunately, that doesn’t really help me calculate weeks of supply in a field/column.

Anyone else have any suggestions?

Userlevel 5
+1

Here’s what I’ve come up with to determine the Average Weeks of Supply:

``=Sum(IIf( [INTran.TranType] = 'INV', [INTran.Qty], 0)) / DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]),  ), Today())``

Basically taking the total qty sold and dividing that by the number of weeks between the 1st receipt date and today. Returns accurate results from what I can tell.

Where I’m currently stuck is I’m trying to now take the total qty available using Max( [INLocationStatus.QtyAvail], ) and trying to divide that by the above formula. Problem is I’m getting a “Divide by Zero” error and not sure how to work around that.

Userlevel 7
+12

Hi @mikeho

Could you please share GI or report that you developed, It may use by others.

Thanks

Userlevel 7

Hi @mikeho - were you able to find a solution? Thank you!

Userlevel 5
+1

Hi @Chris Hackett - I have not yet found a solution for this, unfortunately.

Userlevel 5
+1

In case anyone else can use it, our new VAR was able to assist in producing a calculation that worked for our needs:

Average Weekly Sales:

=IIF(DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]), ), Today())>0,Sum(IIf( [INTran.TranType] = 'INV', [INTran.Qty], 0)) / DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]), ), Today()), 0)

Weeks of Supply:

=IIF((IIF(DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]), ), Today())>0,Sum(IIf( [INTran.TranType] = 'INV', [INTran.Qty], 0)) / DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]), ), Today()), null))<>0, MAX([INLocationStatus.QtyAvail])/(IIF(DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]), ), Today())>0,Sum(IIf( [INTran.TranType] = 'INV', [INTran.Qty], 0)) / DateDiff( 'week', Min(SWITCH( [INTran.TranType] = 'RCP', [INTran.TranDate]), ), Today()), null)), 0 )

Userlevel 7

Thank you for sharing this with the community @mikeho !