ltannous
3rd March 2003, 05:51
How can I create a formula for a chart to display the top 10 inventory items/values

I can get the stock levels, but not sure on how to get the values.
The values should be tiitm001.copr * tiitm001.stoc

This is what I have for the current chart

select sum(tiitm001.stoc), tiitm001.item
from tiitm001
where tiitm001.item = tiitm001.item
group by tiitm001.item
order by tiitm001.stoc desc
selectdo
CHART_CATEGORY_IN(cat.in, tiitm001.item)
CHART_DATA_IN(1, cat.in, tiitm001.stoc)
cat.in = cat.in + 1
endselect
CHART_DEF_DATA("INVENTORY VALUES", "",1, 0.0)
CHART_DEF_CATEGORIES(1, 10, "", "", 1)
CHART_DRAW()
CHART_DISCONNECT()

shah_bs
3rd March 2003, 06:19
Since you want the top ten items by value, you will need to device an algorithm that will use arrays to keep track of the 10 high values, along with the respective item code and quantity. Then, when the array is full, pass the item code and the value (and stock quantity) to the graph. In other words, the 'select' loop will be used to populate the array - and then a 'for-loop' to send the values to the graphing system.

Of course, since you want to show two bars - one for quantity and one for value - you will need to add a series to the graph.

(The value at Standard Cost will be as you mention - tiitm001.stoc*tiitm001.copr. By the way, you do not need to use sum(tiitm001.stoc) - there IS only one record per Item in tiitm001).