Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Warehouse Inventory Value By Item

I currently calculate the values of multiple storerooms by a Facility Number.  Here is my script:

Value:

LOAD

    FacilityNumber,

    MonthStart(OrderDate)as OrderDate,

    Sum(ExtendedCostPrice) as Value

Resident Value_Temp

Group by FacilityNumber,  MonthStart(OrderDate);

Left Join (Value)

LOAD FacilityNumber,

    OrderDate,

    Num(If(FacilityNumber=Peek(FacilityNumber), Value+Peek(RunningTotal), Value), '$ 0,000') as RunningTotal

Resident Value

Order By FacilityNumber,  OrderDate


This works ok, assuming you have at least one transaction per month.

Now I'm being asked to do the same calculation but by Facility AND Item.  I tried this:


Value:

LOAD

    FacilityNumber,

    ItemNumber,

    MonthStart(OrderDate)as OrderDate,

    Sum(ExtendedCostPrice) as Value

Resident Value_Temp

Group by FacilityNumber, ItemNumber, MonthStart(OrderDate);

Left Join (Value)

LOAD

    FacilityNumber,

    ItemNumber,

    OrderDate,

    Num(If(FacilityNumber=Peek(FacilityNumber) and ItemNumber = Peek(ItemNumber), Value+Peek(RunningTotal), Value), '$ 0,000')          as RunningTotal

Resident Value

Order By FacilityNumber, ItemNumber, OrderDate;

The problem I'm having is what I mentioned above, if you don't have at least one transaction per month, you get 'gaps' in the data where there is no running total for that month.

Here is an example of the problem:

Item NumberFacility NumberRunning TotalRevenueOrder Date
4660884506$744$7444/1/2015
4660884506$744$08/1/2015
4660884506$992$2481/1/2016
4660884506$744($248)2/1/2016
4660884506$0($744)3/1/2016
4660884506$992$9924/1/2016
4660884506$1,239$2485/1/2016
4660884506$744($496)8/1/2016
4660884506$248($496)9/1/2016
4660884506$248$01/1/2017
4660884506$496$2482/1/2017
4660884506$496$03/1/2017

As you can see if the user selects a month in between the months highlighted in red (Like 12/1/2016 or 9/1/2015), they get zero for the running total, which is incorrect.

How can I modify this script so that it 'fills in' the missing months with the correct running total ?  I've reviewed posts about generating missing data on this site but I can't find an answer for this specific example.

Don

3 Replies
aarkay29
Specialist
Specialist

Not applicable
Author

I've read that, lots of good examples, however none for having multiple warehouses and multiple items in the same table where you need the value of Warehouse/Item for each date.

sunny_talwar

May be look at this

The As-Of Table