Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
scheibercamo
Contributor III
Contributor III

How do I perform a sum of values for a unique field name within a field?

For example:

IncomeManaged Section 05
500Cats
600

Cats

784

Dogs

839

Cats

541Dogs

I want to know the SUM income of all field names "Cats" under "Managed Section 05"

1 Solution

Accepted Solutions
oknotsen
Master III
Master III

sum( { < [Managed Section 05] = {"Cats"} > } Income)

It is called "Set Analysis". If you search on that, you will find a lot of information.

May you live in interesting times!

View solution in original post

12 Replies
oknotsen
Master III
Master III

sum( { < [Managed Section 05] = {"Cats"} > } Income)

It is called "Set Analysis". If you search on that, you will find a lot of information.

May you live in interesting times!
dsharmaqv
Creator III
Creator III

create a pivot chart with expression

sum(income) and dimension as Managed Section 05

enable partial sum from object properties > presentation tab

Not applicable

Hi Ricky,

Please use the below code..

Sum( { < [Managed Section 05] = {‘Cats’} > } Income)



Regards,

Rajesh R. S.

OmarBenSalem

You can perform this by using set expressions.
Let me explain, Sum(income) is the expression we're working with. Now, if I want to just focus on some income, like in your case, juste sum(income) of the cats.

This is how we should proceed, go to same expression and edit it as follow:
1) the first step is to add {<>} : sum({<>}income) : this is where we're going to add our 'condition'

2) enter the condition : [Managed Section 05] = {‘Cats’}

a) Let's explain this: [Managed Section 05] is the field we're working with. We want to make selections in the field. In fact we want only to work with "Cats" => [Managed Section 05]= {  'Cats'  } (we allways open the {} to put a value in, if the value is numeric, don't use quotes , if it's a string like in our case, use the quotes; if it's an expression, please surround it with double quotes..)

3) Now, the expression has become like this : sum({<   [Managed Section 05] = {‘Cats’}  >}    income) : and this is how we read it : The sum of income for the managed section05 which has a value = Cats.

Hope this answered your question !

Omar,

scheibercamo
Contributor III
Contributor III
Author

Rajesh RS wrote:

Hi Ricky,

Please use the below code..

Sum( { < [Managed Section 05] = {‘Cats’} > } Income)



Regards,

Rajesh R. S.

Fantastic. So I have a few follow-up questions/concerns:

I created:

Count ( { < Managed Section 05 ] = { 'Cats'} > } Income ) .... which worked fine only if I "inserted" income by using the add fields tool to the right. Also, for some reason it duplicated the values but I simply divided by 2. Why did it duplicate?

Now, instead of 'Income' I want to add a different field - 'ID' - for which I have to know the count of distinct Cat IDs (some repeat):

IDManaged Section 05
RS34

Cats

KA78

Dogs

ST56

Cats

HG49Dogs
TY87Cats
RS34Cats
TY87Cats
ST56Cats
GH65Dogs
MD12Dogs
KI90Cats

The following attempt didn't work:

Count ( { < Managed Section 05 ] = { 'Cats'} > } Count ( { Count ( { 1 } distinct ID ) )


Why? All the help is much appreciated!

scheibercamo
Contributor III
Contributor III
Author

Fantastic. So I have a few follow-up questions/concerns:

I created:

Count ( { < Managed Section 05 ] = { 'Cats'} > } Income ) .... which worked fine only if I "inserted" income by using the add fields tool to the right. Also, for some reason it duplicated the values but I simply divided by 2. Why did it duplicate?

Now, instead of 'Income' I want to add a different field - 'ID' - for which I have to know the count of distinct Cat IDs (some repeat):

IDManaged Section 05
RS34

Cats

KA78

Dogs

ST56

Cats

HG49Dogs
TY87Cats
RS34Cats
TY87Cats
ST56Cats
GH65Dogs
MD12Dogs
KI90Cats

The following attempt didn't work:

Count ( { < Managed Section 05 ] = { 'Cats'} > } Count ( { Count ( { 1 } distinct ID ) )


Why? All the help is much appreciated!

scheibercamo
Contributor III
Contributor III
Author

Fantastic. So I have a few follow-up questions/concerns:

I created:

Count ( { < Managed Section 05 ] = { 'Cats'} > } Income ) .... which worked fine only if I "inserted" income by using the add fields tool to the right. Also, for some reason it duplicated the values but I simply divided by 2. Why did it duplicate?

Now, instead of 'Income' I want to add a different field - 'ID' - for which I have to know the count of distinct Cat IDs (some repeat):

IDManaged Section 05
RS34

Cats

KA78

Dogs

ST56

Cats

HG49Dogs
TY87Cats
RS34Cats
TY87Cats
ST56Cats
GH65Dogs
MD12Dogs
KI90Cats

The following attempt didn't work:

Count ( { < Managed Section 05 ] = { 'Cats'} > } Count ( { Count ( { 1 } distinct ID ) )


Why? All the help is much appreciated!

OmarBenSalem

Now, that we have executed the first step; we want to be able to count the distinct id for the cats?
Here's how you perform it :
1) The basic expression is :  count(distinct ID)
2) Now we want to count the distinct ID of specific thing : cats

=> count(distinct {<[Managed Section 05]={'Cats'}>}  ID)
What this does is: count the distinct ID for the Cats.

If I want to count the distinct ID for every managed section (cats, dogs, or whatever)

Use a table:

- As dimension: [Managed Section 05]

- measure: count(distinct {<[Managed Section 05]=>}  ID)

=> which means, count distinct id for all the managed section

scheibercamo
Contributor III
Contributor III
Author

Thanks, works great.