Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
mfarslnn
Contributor
Contributor

How to sum values based on another field value

Hello,

 

I have a table like this;

  • field              -         value
  • a              -              10
  • a              -              15
  • b              -              5
  • c              -              20
  • c              -              30
  • c              -              8

 What i want to do is sum up the values of a and c fields. But while summing up the a values i want to subtract b values from the sum of a. For example i want to see a = (10+15-5)=20 and c = (20+30+8). That's what i want to see as a result.

Any help would be appreciated.

Thanks.

5 Replies
Thiago_Justen_

Sum(a)-Sum(b)+Sum(c)

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
mfarslnn
Contributor
Contributor
Author

This gives 25-5+58=78 which i dont want to see. I want a result set like this;
a - 20 (10+15-5)
c - 58

Thiago_Justen_

Create a table with:

Dimension:  Valuelist('A','C')

Expression: If(Valuelist('A','C')='A',RangeSum(a,-b),Sum(c))

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
Wlad_Masi
Employee
Employee

(A-B): Sum({<Field={'a'}>}Value) - Sum({<Field={'b'}>}Value)

(C):  Sum({<Field={'c'}>}Value)

 

 

To help users find verified answers, please don't forget to mark a correct resolution or answer to your problem or question as correct.
PuriVelasco
Creator
Creator

Hello,

do you resolve your problem? I have a similar question.

Thank you very much.