Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
yes only the rows belonging to the COD_PUNTO having max(date).
sure there are more cod_punto
i don't know this function P()
i tried it do an error: =Sum({<COD_PUNTO=P({<DATA_IN={'$(=Max(DATA_IN))'>}),ANNOIN={'$(=GetFieldSelections(ANNOTEMPO))'},MESEIN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'},STATO_IN={'INGRESSO'}>} CONSUMO_TOT_ANNUO)
"error in set modifier element in function set"
have a look at qlik documentation, in chapter set analysis
i wrote the set rapidly and it maybe syntacticaly incorrect
this part should be better
COD_PUNTO=P({<DATA_IN={'$(=Max(DATA_IN))'}>}COD_PUNTO)
no sorry in this way it return 0
=Sum({<COD_PUNTO=P({<DATA_IN={'$(=Max(DATA_IN))'}>}COD_PUNTO),ANNOIN={'$(=GetFieldSelections(ANNOTEMPO))'},MESEIN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'},STATO_IN={'INGRESSO'}>} CONSUMO_TOT_ANNUO)
problem with date format
COD_PUNTO=P({<DATA_IN={'$(=date(Max(DATA_IN),'DD/MM/YYYY'))'}>}COD_PUNTO)
no is not, always 0
=Sum({<COD_PUNTO=P({<DATA_IN={'$(=Date(Max(DATA_IN),"DD/MM/YYYY"))'}>}COD_PUNTO),ANNOIN={'$(=GetFieldSelections(ANNOTEMPO))'},MESEIN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'},STATO_IN={'INGRESSO'}>} CONSUMO_TOT_ANNUO)
be careful with field names !!!!!
in examples you have mese_in, anno_in
so you have to put those names in set analysis to conform to your data
=Sum({<
COD_PUNTO=P({<DATA_IN={'$(=date(Max(DATA_IN),'DD/MM/YYYY'))'}>}COD_PUNTO),
ANNO_IN={'$(=GetFieldSelections(ANNOTEMPO))'},MESE_IN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'}>} CONSUMO_TOT_ANNUO)
nono the name are correct look i always wrote those kind of fields, perhaps in first example i wrote those...
the names are correct and this i write result 0, sorry
=Sum({<COD_PUNTO=P({<DATA_IN={'$(=Date(Max(DATA_IN),"DD/MM/YYYY"))'}>}COD_PUNTO),ANNOIN={'$(=GetFieldSelections(ANNOTEMPO))'},MESEIN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'},STATO_IN={'INGRESSO'}>} CONSUMO_TOT_ANNUO)
it works here (i don't have field STATO_IN)
Are you sure there are values with this STATO_IN correponding to you selection ?
yes, can you upload this example please so i can try to use this?
here is the code for the script
TIME_TABLE:
load * inline [
ANNOTEMPO,MESETEMPO
2018,12
2018,3
2018,1
]
;
t:
load * inline [
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,10/10/2018,300
];
Set vAnnoTempo = GetFieldSelections(ANNOTEMPO);
Set vMeseTempo = GetFieldSelections(MESETEMPO);
exit script;
and the expression in the graph :
=Sum({<
COD_PUNTO=P({<DATA_IN={'$(=date(Max(DATA_IN),'DD/MM/YYYY'))'}>}COD_PUNTO),
ANNO_IN={'$(=GetFieldSelections(ANNOTEMPO))'},MESE_IN={'$(=Concat(GetFieldSelections(MESETEMPO, chr(39) & ',' & chr(39))))'}>} CONSUMO_TOT_ANNUO)