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: 
PabloOrtiz
Partner - Creator
Partner - Creator

selecting a value in a table of intervals

Hi all, I have the following situation:

A table of intervals:

   

ServicioImporteDesdeImporteHastaPorcentaje
S1050002
S15001150003
S1150019999994
S20100002
S210001200003
S2200019999994

On the other hand I have a service table with some amounts:

ServicioCosteServicio
S16.000,00 €
S222.000,00 €

I need to get the following result table:

 

CodServicioCosteServicioPorcentaje
S16.000,00 €3
S222.000,00 €4

Thanks in advance.

1 Solution

Accepted Solutions
sunny_talwar

Look at the attached:

Capture.PNG

View solution in original post

9 Replies
swuehl
MVP
MVP

Have a look at the INTERVALMATCH LOAD prefix in the extended version.

IntervalMatch

sunny_talwar

Try this:

Table:

LOAD Servicio,

    ImporteDesde,

    ImporteHasta,

    Porcentaje

FROM

[https://community.qlik.com/thread/212217]

(html, codepage is 1252, embedded labels, table is @1);

Table2:

LOAD * Inline [

Servicio, CosteServicio

S1, 6000

S2, 22000

];

Left Join (Table2)

IntervalMatch (CosteServicio, Servicio)

LOAD ImporteDesde,

  ImporteHasta,

  Servicio

Resident Table;

Left Join (Table2)

LOAD *

Resident Table;

DROP Table Table;


Capture.PNG

PabloOrtiz
Partner - Creator
Partner - Creator
Author

Thanks, i know the intervalmatch function, but the problem is that the values of the CosteServicio are dinamic, it depends of the users selections. I need a dinamic match between CosteServicio and Porcentaje.

sunny_talwar

How does user enter those values? Can you share a sample?

swuehl
MVP
MVP

Maybe like this in a chart with dimension Servicio

=Min( Aggr( If( CosteServicio <= ImporteHasta, Porcentaje), Servicio, ImporteHasta))

PabloOrtiz
Partner - Creator
Partner - Creator
Author

Example:

Date                Servicio     CosteServicio

01/01/2016          S1                    3.000

01/01/2016          S1                    3.000

01/01/2016          S2                    11.000

01/01/2016          S2                      1.000    

01/01/2016          S2                    10.000

02/01/2016          S1                      5.000    

02/01/2016          S1                    20.000

For 01/01/2016 as a user selecction

Date                Servicio     CosteServicio

01/01/2016          S1                    6.000

01/01/2016          S2                    22.000

I need to calculate the Porcentaje for every date

swuehl
MVP
MVP

And how are these fields related? Maybe just add Date to the aggr() dimensions.

sunny_talwar

Look at the attached:

Capture.PNG

PabloOrtiz
Partner - Creator
Partner - Creator
Author

Thank you very much, is the solution I was looking for.