Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Converting the field value (Quantity) into interval values (Quantity_Range)

ProductQuantityQuantity_Range
ABC50-5
ABC106-15
ABC516-20
ABC1221-32
ABC333-35
ABC535-40

I have a table with 2 fields (product and quantity). I need to create another field which will convert my quantities into a range. Please provide a solution

4 Replies
tresesco
MVP
MVP

Have a look at class()

PrashantSangle

If your interval period is constant then you can use Class(),

If not then use if() to create bucket

like if(fieldName>0 and fieldName<6,'1-5',

          if(fieldName>5 and fieldName<16,'6-15',

               if(fieldName>15 and fieldName<21,'16-21','>21'

)))


Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
jaumecf23
Creator III
Creator III

Hi,

Attached you can find a possible solution.

Anonymous
Not applicable
Author

will the if condition be suitable? My quantity field values may vary. I need to set the Quantity_Range values with respect to the cumulative sum of the Quantities.

By using this i can calculate the Sum(Price) for the Quantities.

I need to get the following output:

Sales:    

ProductQuantityQuantity_RangePrice
ABC50-5520
ABC106-151100
ABC516-20600
ABC1221-321800
ABC333-35450
ABC535-40750

where my price is calculated based on the pricing table:

Product:

PRODUCTSTARTENDPRICE
ABC13100
ABC415110
ABC1630120
ABC3140150

I need to calculate the price based on the Quantities sold in sales table.

In Quantity=5, then Price = 100*3 (First 3 quantities) + 100*2 (remaining 2 quantites) = 520

For Quantity = 10, (It is considered as 15  (5+10) Quantities, but the pricing starts from 6-15 quantities, neglecting the pricing range of the first 5 quantities.) 110*10=1100.

Similarly i need to calculate the price of the remaining Quantity in the sales table.