Reputation: 59
i have a table in tableau and i wanna create a calculated field based on a filter. Can someone help me in finding the solution for the following logical statement.
I have a table which contains some customers. It also contains some special customers say 'members'. Now I wanna show the total amount of billing for members customers and total amount for the remaining ones.
I have special range for these member customers ID. Ids lies between 300 and 399, both inclusive.
Please help. Thanks in advance
Upvotes: 1
Views: 5140
Reputation: 604
I assume that the measure you want to sum is the Customer Pay. Then, you can do this in three neat steps.
First Step: Create a calculated field called 'Customer Type'
IF [Customer Code] >= 300 AND [Customer Code] <= 399 THEN 'Member' ELSE 'Normal' END
Second Step: Create a calculated field called 'Member Total Billing Amount'
SUM(IF [Customer Type] = 'Member' THEN [Customer Pay] END)
Third Step: Create a calculated field called 'Non-member Total Billing Amount'
SUM(IF [Customer Type] = 'Normal' THEN [Customer Pay] END)
You can now drag Member Total Billing Amount and Non-member Total Billing Amount measures into the view as desired.
Note:
The calculated field called 'Customer Type' will be saved under Dimensions. So, go up there and look for it.
I have only named the calculated fields for illustration purposes. Feel free to change it to what is more intuitive for you.
Another thing to consider, depending on your needs, will be to add Customer Type on the Color Marks card and it will divide Customer Pay into 'Members' and 'Normal'.
Upvotes: 2