Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis. Using monthdate to calculate stock

Hi there.

Pretty new to QS and I'd really appreciate your help.

I'm trying to calculate the stock of products labelled in group 1 by the end of each month (the dimension will show the last day of each month).

What I need to set is as follows:

  • Each product has a purchase date and a selling date.
  • For each reference, if by the end of each month the purchase date is previous to that moment and the selling date isn't, then that reference will be part of the stock.

I'm trying (unsuccessfully) something like:

count({$<group={1}, adquisition_date={"<=$(MonthEnd(?????))"}, selling_date-={"<=$(MonthEnd(?????)"}>}product_reference)

Thank you.

M.

5 Replies
Not applicable
Author

If there is something else I can add to clarify the situation or whatever needs to be considered on my side please ask.

Also, if you think my approach is wrong, I'd appreciate any comment very much.

Thanks.

krishna20
Specialist II
Specialist II

Hi,

Please share the dimension you need to take and the date fields. I understood that you need to calculate MTD sales. If not please let me know what exactly you need to achieve.

Regards

Krishna

Not applicable
Author

Hi, Krishna.

Thanks for replying.

Data available

Fields

  • product_reference: unique id for each product. There's only one unit of every product
  • purchase_date (of the product)
  • selling_date (of the product)
  • product_group: just a product classfication

Example:

product_referencepurchase_dateselling_dateproduct_group
29.12.289429/01/141
18.11.289529/01/143
41.9.289630/01/1424/04/20141
21.10.289731/03/1402/04/20143
15.10.289831/03/143
12.8.289931/03/1403/04/20141
26.4.290031/03/1417/11/20141
41.9.290131/03/1424/04/20144
26.9.290231/03/1407/04/20141
42.8.290331/03/143
15.8.290431/03/143
15.9.290531/03/1402/04/20144
18.7.290631/03/1426/05/20145
14.8.290731/03/142
15.8.290831/03/143
41.7.290931/03/144
15.10.291031/03/142

Note: those products with blank selling date have not still been sold (to the present date), so they're part of the stock.

Note 2: for example, product 41.9.2896, in line 3 would be part of the stock on 31/01, 28/02 and 31/03 but not on 30/03, because it was sold the 24th of April.

Dimension

                                     

end_month
31/01
28/02
31/03
30/04
31/05
30/06
31/07
31/08
30/09
31/10
30/11
31/12
31/01
28/02
31/03
30/04
31/05
30/06

What I'm looking for

A graph showing different lines, each one related to a product_group and the variation of product units through time.

Example:

Thanks anyway!

krishna20
Specialist II
Specialist II

Hi ,

Are you focusing to show the counts for Product_Reference in the condition Product_group =1 only or for all products?

Because, you have mentioned before like this

count({$<group={1}, adquisition_date={"<=$(MonthEnd(?????))"}, selling_date-={"<=$(MonthEnd(?????)"}>}product_reference)


Regards


Krishna

Not applicable
Author

Please don't consider my initial statement because, due to my lack of knowledge, I've surely written something incorrect.

What I'd want to plot is what I explain in my reply:

  • One line for each group, showing what the stock was for each group at the end of each month (in the image posted there's only one line, as an example).
  • And the stock is the addition (counting) of all the references of the same group, considering its purchasing and selling dates as explained before.

Thanks.

M.