Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional sum in Qliksense

Hello,

I am trying to do a conditional sum in Qliksense.

I have used the below two methods but none of them work.

1) First way:

if ((current_grade ='A','A-','B','B+','B-','C','C+','C-','D','D+','F'),

  SUM([Grade Value] * (credit_hours)) / Sum(credit_hours))

2) Second way:

Sum(

  if (current_grade ='A','A-','B','B+','B-','C','C+','C-','D','D+','F'),

  SUM([Grade Value] * (credit_hours)) / Sum(credit_hours)

    )

What I basically need is that only the grades that I have selected above be used in calculation of GPA.

Let me know if anyone have come across this problem.

BR,

Vipin Saroha

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

SUM({<current_grade *= {'A','A-','B','B+','B-','C','C+','C-','D','D+','F'}>}[Grade Value] * credit_hours) /

Sum({<current_grade *= {'A','A-','B','B+','B-','C','C+','C-','D','D+','F'}>}credit_hours))


Hope this helps you.


Regards,

jagan.

View solution in original post

6 Replies
sinanozdemir
Specialist III
Specialist III

Hi VIPIN,

You can try to use set analysis, like the below:

SUM({<current_grade = {'A','A-','B','B+','B-','C','C+','C-','D','D+','F'}>}[Grade Value] * (credit_hours))

     / Sum({<current_grade = {'A','A-','B','B+','B-','C','C+','C-','D','D+','F'}>}credit_hours)

Hope this helps.

robert_mika
Master III
Master III

In this solution:

if ((current_grade ='A','A-','B','B+','B-','C','C+','C-','D','D+','F'),

  SUM([Grade Value] * (credit_hours)) / Sum(credit_hours))

you will need OR after each value

if ((current_grade ='A',OR current_grade='A-', OR...,

  SUM([Grade Value] * (credit_hours)) / Sum(credit_hours))

Sinan solution is the way to go as IF will increase the calculation time but you can use IF in this form

IF(MATCH(current_grade,'A','A-','B','B+','B-','C','C+','C-','D','D+','F'),(SUM([Grade Value] * credit_hours)) / Sum(credit_hours))

Not applicable
Author

Hello Sinan,

Thank you for this, the set analysis works fine.

The problem arises when there is only one selection available, at that time it does not show updated info.

See the image attached, in this selection the GPA Gauge should show 4, but it gets stuck with the last value.

Let me know if you can help.

GPA calc.PNG

Not applicable
Author

Hello Robert,

I tried bot the suggestions that you have mentioned, using OR as well as Match function.

But none of them work correctly, they do not show any data.

Could you suggest something else?

Complete formula with OR:

if ((current_grade ='A',OR current_grade='A-', OR current_grade='B',

      OR current_grade='B-',OR current_grade='B+',OR current_grade='C',

     OR current_grade='C-', OR current_grade='C+', OR current_grade='D'

     OR current_grade='D+',OR current_grade='F'),

  SUM([Grade Value] * (credit_hours)) / Sum(credit_hours))

robert_mika
Master III
Master III

Could you post your file?

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

SUM({<current_grade *= {'A','A-','B','B+','B-','C','C+','C-','D','D+','F'}>}[Grade Value] * credit_hours) /

Sum({<current_grade *= {'A','A-','B','B+','B-','C','C+','C-','D','D+','F'}>}credit_hours))


Hope this helps you.


Regards,

jagan.