Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
sculptorlv
Creator III
Creator III

Please help with intervals

Good day! I am looking for the solution.

I have a table like TABLE_1 with sales contract parameters:

Client   Min_Quantity   Price

John    1                              20 Eiro

John    2                              10 Eiro

John    5                              5 Eiro

Sara     1                              15 Eiro

Sara     3                              10 Eiro

 

 

And I have TABLE_2 with exact sales data:

Client   Sold

John     1

Sara      4

 

I need to compare these two table in order to calculate correct price based on the following logic:

 IF John bought at least 5 Kg, his price would be 5 Eiro, 

Then IF John bought at least 2 Kg, his price would be 10 Eiro, 

Then IF John bought at least 1 Kg, his price would be 20 Eiro, 

else ... (can make Null() value right now, but in fact have to be 20 Eiro)

 

According to this logic, the result have to be like in Table_3:

Client    Correct Price

John     20 Eiro

Sara     10 Eiro

 

I need to understan, how to calculate Table 3 

Labels (1)
1 Reply
marcus_sommer
MVP & Luminary
MVP & Luminary

You need multiple steps for this task. At first will be the creating of an interval in two separate fields. Then you could use an intervalmatch to populate the intervals to a discrete value and then you could consider if you keep it as an own table or if you join/map these value to the fact-table (most often I match it to the facts because the link-table from the intervalmatch could become very large and decrease the performance). For the howto take a look here:

Creating-a-Date-Interval-from-a-Single-Date
IntervalMatch

That the examples are with dates doesn't matter because a date is also just a (formatted) number.

- Marcus