Announcements
cancel
Showing results for
Did you mean:
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

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

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago
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

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
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.
Creator

Hello,

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

Thank you very much.