8 Replies Latest reply on May 26, 2016 2:31 AM by Mahfooj Khan

# How to count the number of different categories within one dimension

I'm not sure if I worded that correctly in the title but:

I have 1 dimension called Sales that contains two categories: A & B.

I am able to count the number of sales in total for the whole dimension, using a calculated field: Count([Sales]).

However, I want to be able to count the total number of sales for A, and separately for B, within this single dimension. Preferably, I would like to create two different calculated fields, that can be use separately in rows/columns.

Is there a way of doing this?

Thanks

• ###### 1. Re: How to count the number of different categories within one dimension

Yeah this can be done! Can you share your sample data in text format or share the workbook in .twbx format?

• ###### 2. Re: How to count the number of different categories within one dimension

I am unable to share the data/sample as it is sensitive to exposure and confidential, is there an easy way to explain?

• ###### 3. Re: How to count the number of different categories within one dimension

I'm not asking you to share the exact data just create few columns and rows with the same format with dummy values. Just 10-20 records.

• ###### 4. Re: How to count the number of different categories within one dimension

Hi, Sebastian

You may try creating those 2 calculated fields as follows,

Sales Count of A =

If dimension='A' then count([Sales]) else 0 end

Sales Count of B =

If dimension='B' then count([Sales]) else 0 end

Please let me know if this helped.

-Mia-

• ###### 6. Re: How to count the number of different categories within one dimension

Ok so attached is an example workbook and the data file. Basically you will see that I already have two measures, Invoices and Orders which I need displaying like they are next to each product. I have then counted the number of sales in each one which in this case is 1 for each product (the real data is one line for every product therefore there is more than one by each product). However, I would like to make a calculated field that only counts A, and only counts B separately, so that I can name them Sales A and Sales B in the columns, much like Invoices and Orders. Thanks for you help.

• ###### 7. Re: How to count the number of different categories within one dimension

I have managed to do it using Count and IF functions in two separate calculated fields:

Count(IF [Sales] = 'A' then [Sales] end)

and named the Field Sales A

Repeated for Sales B

Thanks for the Help

• ###### 8. Re: How to count the number of different categories within one dimension

Yeah Its correct!