How to calculate count percentage of specific field?

Hi Friends,

I have a field called Sales_id. I want to calculate the count percentage of sales id.

for example:
Numerator: distinct count of sales id for company 001 is 51.
Denominator: distinct count of sales id for all the company id is 2672

I want to calculate percentage of this sales id 51/2672 = 1.91%

I have created calculated field with following formula

(count(Sales_Id) / countOver(Sales_Id, )) * 100

and implementing in KPI but it’s not working in any visualization. Can some one help me to calculate percentage

Thanks,
Satya

Hi @SatyaPaleti,
When you say it’s not working in any visualization..are you receiving an error that’s not allowing you to complete the calculated field or is it producing the wrong number(s)?

It looks like your calculated field is just dividing the same number by the same number since you’re leaving your aggregation level empty on the denominator. So wouldn’t you want to run the count of sales id, aggregated by company, divided by the overall sales id count?
So maybe use a countOver in the numerator as well and aggregate by company.

Then in terms of finding a percent, I’d be more inclined to remove the ‘*100’ and instead change the ‘show as’ option to percent.

Let me know if you have any additional questions

1 Like

Hi Brett,

Thanks for your response on this. I am getting below error

I want to calculate count of sales id for selected company id divided by count of sales id for all the company id’s

Can you please help me with providing formula?

Hi @SatyaPaleti,
You’re receiving that error because you’re trying to utilize a calc. field that includes a field not being included in your visual (I would assume ‘Sales ID’ for your case).

In terms of a calculated field for what you’re trying to accomplish, you could try something like:

countOver({Sales ID}, [Company ID], PRE_AGG) / countOver({Sales ID}, , PRE_AGG)

Hi @SatyaPaleti,
Following up here as it’s been awhile since we last heard from you, did you have any additional questions regarding your post?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!