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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
danosoft
Specialist
Specialist

Filter Chart with variable

Hi i have those two variables:

Set vAnnoTempo = GetFieldSelections(ANNOTEMPO);

Set vMeseTempo = GetFieldSelections(MESETEMPO);

ANNOTEMPO and MESETEMPO are fields of my TIME_TABLE

i want those variables takes from my fields selection:

When i choose for example Anno: 2017          Mese: 2

I want my chart will be filter from my vAnnoTempo and vMeseTempo, but its not start

The set analisys expression i have in my chart is:

=Sum({<ANNO_IN={"=$(vAnnoTempo)"},MESE_IN={"=$(vMeseTempo)"}>} CONSUMO_TOT_ANNUO)

ANNO_IN and MESE_IN are my fields in my CONTR table.

p.s.: CONTR table and TIME_TABLE are not connected, and this is correct, i not want are connected, i want do my filter with set analisys in this way, becouse for every dimension i have in my chart i need to do a different set analisys

Thanks

49 Replies
danosoft
Specialist
Specialist
Author

no, in this way is wrong it return: 0

=Sum({<DATA_IN={'$(=Aggr(Max(DATA_IN), COD_PUNTO))'},ANNOIN={'$(=GetFieldSelections(ANNOTEMPO))'},MESEIN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'},STATO_IN={'INGRESSO'}>} CONSUMO_TOT_ANNUO)

p.s.: i ask if you can post your .qvw you did for your example post before

olivierrobin
Specialist III
Specialist III

i just typed in the code sent before and created a graph and 2 listboxes .. and i didn't save it !!!!!!

in which table is you field cod_punto ?

do you use it as dimension in your graph ?

danosoft
Specialist
Specialist
Author

ok, sorry for asking

cod_punto and data_in is in the table CONTR

and NOT i not use cod_punto like a dimension in my graph, i want use it only in the set analisys for CONSUMO_TOT_ANNUO

olivierrobin
Specialist III
Specialist III

Aggr(Max(DATA_IN), COD_PUNTO  returns 1 value per COD_PUNTO (i.e an array of value)

in tour case, you have to retrieve only 1 value, the question is : which one do you want ?

danosoft
Specialist
Specialist
Author

the Max(DATA_IN) i want return only this record for the same cod_punto

olivierrobin
Specialist III
Specialist III

do you mean you select COD_PUNTO outside the set analysis (via a listbox for example) ?

in this case, you don't need aggr(,cod_punto) as only 1 code is selected

max(date) will be enough

danosoft
Specialist
Specialist
Author

No, i not select a cod_punto via list box...

with my set analisys i want only came back 1 record with one value to use in the sum, the record with maxdate dt_ini

example table:

ANNO_IN,MESE_IN,COD_PUNTO,DATA_IN,CONSUMO_TOT_ANNUO

2018,12,PR01,10/10/2018,100

2018,3,PR01,4/10/2018,50

2018,1,PR02,300

if i do the set analisys in this table it must take in the SUM consumo_tot_annuo the result: 400

NOT 450

olivierrobin
Specialist III
Specialist III

i have some difficulties to understand ....

if you don't care about COD_PUNTO, don't user it in aggr

if you want to select max data_in, use max(data_in) in your set analysis and be careful of the format of the date (you may have to use date(), date#() to format it

danosoft
Specialist
Specialist
Author

thanks, but look at example... i need take the max date about my cod_punto

in example i have 2 cod_punto =     PR01

from this 2 rows i need to take only the row with MAX data_in... so the row with consumo_tot_annuo=100

all that need in the sum like the set analisys i did... but it not work

olivierrobin
Specialist III
Specialist III

you mean you want only the rows  belonging to the COD_PUNTO having max(date) ?

and if there are 2 or more COD_PUNTO ?

so, i think you need

Sum({<COD_PUNTO=P({<DATA_IN={'$(=Max(DATA_IN))'>}),ANNOIN=