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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
ecabanas
Creator II
Creator II

Nearest value

Hi guys,

I have a item price list, and I would like to find the nearest value from a date selected. For example:

Proveedor_TarifaItemIdFromToTarifaTarifa_Id
PROV002831035785601/02/201629/02/20160,8810357856-42401
PROV002831035785601/03/201631/12/20160,5210357856-42430

If I select February, the result has to be: 0,88 if I select APril: 0,52

Many thank's for your help

Eduard

7 Replies
MK_QSL
MVP
MVP

Create something like below in script..

Data:

Load * Inline

[

Proveedor_Tarifa, ItemId, From, To, Tarifa, Tarifa_Id

PROV00283, 10357856, 01/02/2016, 29/02/2016, 0.88, 10357856-42401

PROV00283, 10357856, 01/03/2016, 31/12/2016, 0.52, 10357856-42430

];

Temp:

Load

  From,

  To,

  Month(MonthStart(From, IterNo()-1)) as Month

Resident Data

While MonthStart(From, IterNo()-1) <= MonthStart(To);

Now you can use Month as Filter and =SUM(Tarifa) as expression.

ecabanas
Creator II
Creator II
Author

Hi Manisch

The problem is not in the load scrip, this operation has to be done in a set analisys in a table

Many thank's

MK_QSL
MVP
MVP

Without any change in script, how you get April month here? Have you created master calendar?

ecabanas
Creator II
Creator II
Author

Hi Manisch

Yes, see the example:2016-09-20_10h35_52.png

MK_QSL
MVP
MVP

So this Month field is created based on which field?

ecabanas
Creator II
Creator II
Author

when you select  the month in the upper band, the field shows the mothend value. Is automatic

sunny_talwar

I think you need to look into IntervalMatch‌ or use the logic from this link

Create a table from another