Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all
My calculation for #StockCover produces zero as a result and I don't understand why?
All other calcs work fine.
What am I missing?
StockCoverPreCalc:
LOAD
BusinessUnit,
GLDate,
ShortItemNo,
ItemDesc,
ItemBU3,
Sum(#SalesQty) as #SalesQty,
Sum(#SalesTns) as #SalesTns,
If(GLDate >AddMonths(monthend(today()),-12) and GLDate <=monthend(today(),-0), Sum(#SalesTns/12)) as #AvgeSalesLast12,
If(GLDate >AddMonths(monthend(today()),-12) and GLDate <=monthend(today(),-0), Sum(#SalesTns/12)
/
If(GLDate = today(),Sum(#StockTonnes_PreCalc))) as #StockCover,
Sum(#StockTonnes_PreCalc) as #StockTonnes_PreCalc
Resident StockCoverPreCalc_tmpA
Group by
BusinessUnit,GLDate,ShortItemNo,ItemDesc,ItemBU3
;
Drop table StockCoverPreCalc_tmpA;
Message was edited by: Tim Saddler Heres a qvw with one product only as this might make it easier to understand the issue
Hi I have redone the calculation so that GLDate is in the filter and it now calculates.
This works as Sales are over different GL Dates but Stock is always "Today"
StockCoverPreCalc_tmpA:
LOAD BusinessUnit,
//Date(GLDate) as GLDate,
ShortItemNo,
ItemDesc,
ItemBU3,
#SalesTns,
#SalesQty
FROM
[SalesforStockApp.qvd]
(qvd)
Where Match(OrderType,'O1','O3','O6','OU','O7','CO')//Remove Order Type OH
and GLDate >AddMonths(monthend(today()),-12)
and GLDate <=monthend(today(),-0)
Hi, Tim,
Can you pls list the "GLDate" column as well?
Because you use "GLDate = today()" as a condition, something should be wrong here.
Zhihong
I think today() isn't right as condition and it should look more like:
If(GLDate >AddMonths(monthend(today()),-12) and GLDate <=monthend(today(),-0), Sum(#SalesTns/12)
/
If(GLDate >= monthend(today(), -0),Sum(#StockTonnes_PreCalc))) as #StockCover,
- Marcus
Hi,
try something like this,
If(GLDate >AddMonths(monthend(today()),-12) and GLDate <=monthend(today(),-0), Sum(#SalesTns/12))
/
If(GLDate = today(),Sum(#StockTonnes_PreCalc)) as #StockCover,
Regards
May be if non of the suggestions work, provide a small sample to look at
Sorry this still produces zero
Hi,
do you have value for #StockTonnes_PreCalc for today
Regards
Have posted qvw now
I cannot reload, but I think the issue is related to the numerator. Can you try this:
Sum(If(GLDate >AddMonths(monthend(today()),-12) and GLDate <=monthend(today(),-0), #SalesTns/12))
/If(GLDate = today(),Sum(#StockTonnes_PreCalc)) as #StockCover,
Yes there is a value