0

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)) + "%"

2
  • 1
    Show some sample data. What is the level of detail of the data? that is, what does a single record in the data represent? a Policy? a Transaction? An inquiry? Are there multiple rows that have the same Policy ID? or exactly one? Can Channel_Preference hold values other than Email or Postal? If [Policy_ID] is unique, not repeated in other data rows, then use COUNT() instead of COUNTD() for efficiency Commented Apr 1, 2024 at 2:37
  • 1
    Personally, I would leave the calls to STR(), ROUND(), multiplying by a 100 and appending "%" out of the calculated field. Instead have the field return numeric value, usually between 0 and 1. And then use the Default -> Number Format feature to control how values are displayed Commented Apr 1, 2024 at 2:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.