Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggrégation somme et variables dynamiques

Bonjour à tous,

Voici une petite formule avec des valeurs « en dur » :

=sum({$ <ANNÉE= {2012,2013}, MOIS={août, sept., oct.}>} div(EFF_NB_HEURES,1))

Je souhaite remplacer 2012, 2013 par MinString(ANNÉE) et MaxString(ANNÉE), ainsi que août, sept., oct. par MinString (MOIS) MaxString(MOIS) car ce sont des critères de sélection pour mes calculs.

Mais ça ne marche pas, c'est une syntaxe qui ne semble pas plaire à QlikView…

Avez-vous une idée ? Merci d'avance.

1 Solution

Accepted Solutions
Not applicable
Author

I wrote something not bad :

=Round((((sum({$<DATE_ANNEE = {$(#=NumMax(Num#(MinString(DATE_ANNEE)), Num#(MaxString(DATE_ANNEE))))}>} EFF_NB_HEURES)/8)-(sum({$<DATE_ANNEE = {$(#=NumMin(Num#(MinString(DATE_ANNEE)), Num#(MaxString(DATE_ANNEE))))}>} EFF_NB_HEURES)/8))/(sum({$<DATE_ANNEE = {$(#=NumMin(Num#(MinString(DATE_ANNEE)), Num#(MaxString(DATE_ANNEE))))}>} EFF_NB_HEURES)/8))*100,0.01)&' %'

I'm sure it could be shorter, but it works !

Thanks for all

View solution in original post

12 Replies
Nicole-Smith

=sum({$ <ANNÉE= {'>=$(=MinString(ANNÉE))<=$(MaxString(ANNÉE))'}, MOIS={'>=$(=MinString(MOIS))<=$(MaxString(MOIS))'}>} div(EFF_NB_HEURES,1))

Not applicable
Author

Quelle réactivité, et quelle syntaxe !!!

Malheureusement, comme le montre la copie d'écran, cela n'a pas l'air de plaire à QV, la coloration syntaxique semble indiquer un je ne sais quoi qui va pas…

Nicole-Smith

The syntax highlighting is correct.  When you do calculations within set analysis, it doesn't highlight them like regular calculations.

Not applicable
Author

The result is 0, it should be 491'446. The formula is in a text object, should it be somewhere else ?

Nicole-Smith

Are your months just text fields or are they dual fields?  If they're just text fields, it won't work (you'll need to change them to be duals).

Not applicable
Author

Actually, I have a field with lots of SQL Timestamp. In the script I use this statement to extract month :

Month(EFF_DATE_FIN) as MOIS,

and in the table it appears

eff_date_fin     année     mois     semaine

41103          2012          juil.          28

41138          2012          août        33

I'll see how to change them to be duals.

Thanks

Modified :

In the table viewer, MOIS is $numeric, $integer. I'm not sure statement dual is usefull, and it don't work.

LOAD Dual (string, numrep) as MOIS inline

[string, numrep

janv., 1

févr., 2

mars, 3

avr., 4

mai, 5

juin, 6

juil., 7

août, 8

sept., 9

oct., 10

nov., 11

déc., 12];

DATE:

LOAD EFF_DATE_FIN,

Year(EFF_DATE_FIN) as ANNÉE,

Month(EFF_DATE_FIN) as MOIS,

Week(EFF_DATE_FIN) as SEMAINE

FROM QVD\TACHE.qvd(qvd);

Where is my mistake ?

Nicole-Smith

fong quentin wrote:

In the table viewer, MOIS is $numeric, $integer.     

That's all that matters.  Just needed to make sure the text field was in fact also being represented as a number.

Without having an actual .qvw file to look at, I don't believe I can help you any further.  Can you create a sample file or upload one that is scrambled (Preparing examples for Upload - Reduction and Data Scrambling)?  It would also help to know what you expect to get vs. what you're actually seeing.

Not applicable
Author

Hope it will be helpfull,

Thanks !

Nicole-Smith

Where are you trying to use the calculation on that dashboard?  What is it returning and what do you think it should be returning?