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

Can anyone help me simplify the calculation?

I have a calc like this :

=( Grade1/Garde 1 std)  + (Grade2/Garde2standard)+...............................+ (Grade10/Garde10standard)

For today its 10 what if tomorrow there are many standards. Can you help me with the best solution. And this is the expression calc you can either advise me in data modelling (Scripting)wise or else in expression wise as well.

Jagan MohanAshfaq MohammedJohn Witherspoon

3 Replies
juleshartley
Specialist
Specialist

You could build the expression in the script using a loop and a variable.

let vFormula = (Grade1/Grade1standard);

For i = 2 to 10

     Let vFormula = $(vFormula) & ' + Grade' & i & '/Grade' & i & 'standard)'

Next

Then use vFormula in the script. You may have to be careful with apostrophe's and use chr(39) etc.

juleshartley
Specialist
Specialist

ps. You can of course replace the 10 with a count of the possible options to make it dynamic...


Not applicable
Author

But for static this is fine,

What if I have many calcs and selections considered

Ex : = Count(<Type = super,order='check'Grade1>/(Garde 1 std)  + Count(<Type = super,order='check'>Grade2)/(Garde 2 std) . I think its better to write a big calc just heard from business team there is only 10 standards always.

Just thinking...........................................