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
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'.
Related
I'm working on a project to create a template that uses one of my regular exports and changes the way the data is structured. I've attached a sample spreadsheet below.
https://docs.google.com/spreadsheets/d/1mFo_VpdeXpWkpLqMNnCBAT_93rx_JCjG508VsEwMoL4/edit?usp=sharing
The "Source Data" tab is my export, it's a list of orders where rows are repeated for each unique product that the customer has purchased. The Order Numbers are repeated for as many rows that the order has.
I'm trying to add additional row(s) to each order on my "Corrected Data" tab based on conditions and perform a calculation that would change the data that the additional row outputs.
The conditions / rules are as follows.
To add any additional rows the "Shipping Cost" of the order (column O) must be > 0
If an order has all products with a Tax Class of > 0 then 1 additional row should be added. The Order Number needs to be the same, the "Product Code" (column J) should have "TAXABLE-SHIPPING", the Product Name (column K) should be "Taxable Shipping" and the "Product Price" (column T) needs the following calculation: ROUNDDOWN((ShippingCost/(100+TaxClass)*100),2). Every other column can remain blank.
If an order has all products with a Tax Class of 0 then 1 additional row should be added. The Order Number needs to be the same, the "Product Code" (column J) should have "ZERORATED-SHIPPING", the Product Name (column L) should be "Zero Rated Shipping" and the "Product Price (column T) should be the same as the "Shipping Cost".
If the order has a mixture of Tax Classes then 2 additional rows should be added. The Order Number needs to be the same for both rows, one row should have "Zero Rated"and "ZERORATED-SHIPPING" in the Product Name/Code Columns and the other row should have "Taxable Shipping" and "TAXABLE-SHIPPING". respectively.
The "Product Price" on these two rows needs to do the following calculations and apply to their respective rows.
ZERORATED: ROUNDDOWN(((SUM(Product Prices that have 0 Tax Class)/Order Subtotal)*Shipping Cost),2)
TAXABLE: ROUNDUP(((((SUM(Product Prices that are > 0 Tax Class)/Order Subtotal)*Shipping Cost)/(100+Tax Class)*100),2)
So far, I've managed to get this working with a bit of help to the point where 1 additional row is being added when the Shipping Cost is > 0. This is only with a few select columns rather than the whole dataset. This can be seen in the "Partial Solution" tab.
I don't even know where to begin with the 2nd additional row with multiple tax classes, or how to wrap the calculations into that.
I appreciate that this one is quite lengthy and difficult, perhaps formula isn't the best solution here but I was hoping a single cell array formula would be able to do this. Any help at all pointing me in the right direction would be hugely appreciated! <3
This is my computatiom sheet: (https://docs.google.com/spreadsheets/d/e/2PACX-1vSR3jhKH7FNfuqo_VcemDUoZGNtoUJttCQz8XF0r7c8Qyyc4PWQqqHyxanalb5etA/pubhtml?gid=6282745&single=true)
Name Country Region Unique Region Region Count Sales Representative
Mr Action Taker Dubai EMEA EMEA 5 Eashwari
Mr Responsible Bangalore APAC APAC 7 Chetan
Mr Careful guy Mumbai APAC AMER 3 Khushi
The unique region is computed by UNIQUE function which is giving me the list of unique regions from the inputs that i receive one by one. If a new region is added, the unique list will be appended automatically.
The region count is the count of regions in my input. I have use the MOD function to assign the lead to a sales rep in a chronological fashion so that even distribution is achieved.
In the above sheet, my region count increases by 1 as soon as a new entry is added into the input sheet. When that happens, a sales rep is assigned automatically.
Each region has 4 sales rep.
Now, i have an output sheet below. (https://docs.google.com/spreadsheets/d/e/2PACX-1vSR3jhKH7FNfuqo_VcemDUoZGNtoUJttCQz8XF0r7c8Qyyc4PWQqqHyxanalb5etA/pubhtml?gid=1954161251&single=true)
Name of the Lead Team Sales Representative Notes:
Mr Action Taker EMEA We want to upgrade our subscription
Now, I want to show the sales rep in the output sheet which i have computed in the computation sheet. This shall not change if my computation sheet is updated whenever new entry comes in.
The sales rep shall be from his region team.
use:
=INDEX(IFNA(VLOOKUP(A2:A&" "&B2:B, {
IMPORTRANGE("url_or_id_of_spreadsheet", "Part 2 Computation Sheet!A2:A")&" "&
IMPORTRANGE("url_or_id_of_spreadsheet", "Part 2 Computation Sheet!C2:C"),
IMPORTRANGE("url_or_id_of_spreadsheet", "Part 2 Computation Sheet!F2:F")}, 2, 0)))
I'm new to Tableau so this may be an easy question about computations using RANK. I can't find any tableau HELP or other stack-overflow answer to this. Maybe this is a GROUP question. Maybe it's about OTHER.
I have a data set of 160 countries ( rows ) with a field for jetfuel consumption for each country.
I just want to make a bar chart like the attached image showing the 20 highest fuel-consumption countries by name ranked by jetfuel_consumption ( I can do that much) AND an 21st row computed country name titled "Rest of world" summing the remaining 140 countries together as if it were just another country like the bottom of this model .
I have a working valid computed field labelled "myrank" = RANK(AVG([Jetfuel Consumption]),'desc')
My thought was to simply calculate a new text field that would equal the country name for rank < 21 and then be the string "Rest of World" otherwise.
Such as:
IF ( [therank] < 11 ) [Country] ELSE "Rest of World" END
But that is not valid for an unspecified reason. I know I'm confused already about how to just specify the value of a field without something like SUM or AVG or AGG wrapping it, but this is a larger question.
What's the right way to make this view?
I've created simple dataset:
And I want to group TOP 3 countries by Consumption.
To do it I should create a set (click on Country in Dimension) and select TOP 3 By SUM(Cosumption):
Then create a calculated field to show Countries IN Set and "Others".
IF [Country Set] is a boolean expression "The country IN a set".
Drag and Drop corresponding fields and configure sort, for example:
Sets are convenient to dynamically change, expand and customize any visualization. More detailed: https://help.tableau.com/current/pro/desktop/en-us/sortgroup_sets_topn.htm
Tableau is giving me a hard time, trying to compare two items by percentages. I need to display the percentage different between the number (couintif) of string items based on condition.
Basically, I wrote two calculated fields like:
Calc field #1
IF [Outcome] = "Complete" Then 1 Else 0
Calc field #2
IF [Outcome] = "Pending" Then 1 Else 0
and a third field to get the percentage of pending sales to completed sales
Calc percentage
SUM(Calc field #1 / Calc field #2)
But it's not working. The first two fields work fine, validated them with dataset, but the third calculation doesn't work and always outputs 0
The formula for Calc percentage should be
SUM(Calc field #1) / SUM(Calc field #2)
As both the calculated fields are computed row-wise, it is important to aggregate while using it in a formula.
I have a spreadsheet that tallies sales over time, including sales person, office they work out of, and the price of whatever it is that they sold. I am attempting to create a two-column filtered list by multiple criteria. The data looks like this:
Date Name Office Price
5/5/12 Joe OW 220000
6/1/12 Jim SOL 100000
What I want to be able to do is create a two-column entry that sums the price column, but uses multiple critera from the first three to do so. For instance, "everyone named Jim who sold something in May", and then I'd like to sort that by the top three.
Using items like:
=FILTER( C1:C ; D1:D="OW"; month(B1:B)=month("5/12/12"))
and
=ARRAYFORMULA(frequency(MATCH(E1:E&counta(E1:E),UNIQUE(E1:E&counta(E1:E)),0), MATCH(UNIQUE(E1:E&counta(E1:E)),UNIQUE(E1:E&counta(E1:E)),0)))
I can filter and tally, but I am unable to replace the frequency mentioned above with a summation of the price column.
Rather than using FILTER you could put together something using SUMPRODUCT:
=arrayformula(sumproduct($E$2:$E$3*($C$2:$C$3=C2)))
If you have column E as price and column C as name, this creates a new column that shows the total earnings for each name, next to every instance where that name appears in the array. You can apply further conditions within the SUMPRODUCT call as needed. You could then apply UNIQUE to deduplicate and sort the resulting table to see the top 3.