How to calculate profit when cost and revenue are in same column?

0 votes

Goal: Calculate profit when cost and revenue are in the same column.

Sample Data-set:

 item   account_category   balance
   x                cost         5
   x                cost         5
   x             revenue        12
   y                cost         8
   y             revenue         7

Query: How to create a calculation that gives profit both in terms of absolute cost(i.e., revenue - cost) and percentage of revenue (i.e., (revenue - cost)/ revenue).

Apr 10, 2018 in Tableau by Atul
• 10,240 points
88 views

1 answer to this question.

0 votes

You can create the following calculated fields:

Profit:

SUM(IIF([account_category] = "revenue",[balance],NULL))
-
SUM(IIF([account_category] = "cost",[balance],NULL))

% of Revenue:

(
    SUM(IIF([account_category] = "revenue",[balance],NULL))
    -
    SUM(IIF([account_category] = "cost",[balance],NULL))
)
/
SUM(IIF([account_category] = "revenue",[balance],NULL))
answered Apr 10, 2018 by Atul
• 5,530 points

Related Questions In Tableau

0 votes
1 answer
0 votes
1 answer

How to select column which are needed to create report in tableau

Please follow this process: Make database connection Join tables Go ...READ MORE

answered Sep 26, 2018 in Tableau by AwesomeSauce
• 860 points
44 views
0 votes
1 answer

How to add a story with same sheet with different parameters and filters added in tableau?

Hi Riya, Follow these steps to add sheets/dashboard ...READ MORE

answered Mar 22 in Tableau by Cherukuri
• 31,840 points
85 views
0 votes
1 answer

How to show actual and forecast in same line chart?

Hi Sindhu, Follow the below steps: 1. Create a line ...READ MORE

answered May 23 in Tableau by Cherukuri
• 31,840 points
62 views
0 votes
1 answer

Calculated filed with if-then

Below is the required code:  IF (NOT ISNULL([test2])) ...READ MORE

answered Mar 27, 2018 in Tableau by Atul
• 10,240 points
101 views
0 votes
1 answer

Creating a calculated field with LOD expression

Go ahead and try the following three ...READ MORE

answered Apr 20, 2018 in Tableau by Atul
• 5,530 points
119 views
0 votes
1 answer

Calculation issue: Distinct sum in Tableau

SUM( { FIXED [Brand], [Market]: AVG(Target) } ...READ MORE

answered May 8, 2018 in Tableau by Atul
• 10,240 points
2,884 views
0 votes
1 answer

Creating a calculated field for summing up the values

Well you can use this in your ...READ MORE

answered May 17, 2018 in Tableau by Atul
• 5,530 points
48 views
+1 vote
1 answer
0 votes
1 answer

How to calculate the percent of records within a group in tableau?

 You can click the measure SUM(Number of Records) and ...READ MORE

answered May 8, 2018 in Tableau by Atul
• 5,530 points
270 views