I have a dataset that contains details of customer policies. I am using two calculations below to calculate the percentage that have email preference vs Postal preference.
However there is also a filter being used to look at just the policyholder, or customers that are not the policyholder or both. The filter name is "is_policyholder" and the options are 'Y', 'N', 'All'
The calculated results are not appearing correctly and I am getting results that are over 100% when looking at the two fields when the filter is switched to 'N' or 'All' on tableau e.g Email is showing as 77% and Postal is showing as 61% when 'All' is selected
The calculations I am using are below
code
Email Preference calculation
STR(ROUND(COUNTD(IF [CHANNEL_PREFERENCE] = 'Email' then [POLICY_ID] end) / COUNTD([POLICY_ID] )*100, 2)) + "%"
Postal Preference Calculation
STR(ROUND(COUNTD(IF [CHANNEL_PREFERENCE] = 'Postal' then [POLICY_ID] end) / COUNTD([POLICY_ID] )*100, 2)) + "%"