Implementing a calculated field within my Tableau Viz

Lynn

I have data within tableau that I wish to show a breakdown of USED and FREE storage. However, I need to first filter a specific column to perform 2 different types of calculations. Here is the data

        Total        Free              SKU    
     
        10           5                  A 
        20           1                  A
        5            4                  B
        2            0                  B
        10           5                  C
        10           6                  D

I am wanting to show a tableau bar chart that displays the available, used and total within Tableau. However, I need to first filter out by SKU:

I created this calculated field below as well as this calculated field:

Used = Total - Free

       IF CONTAINS(ATTR([SKU]),'A') or 
       CONTAINS(ATTR([SKU]),'D') 
       THEN SUM([Total]) 
       ELSEIF CONTAINS(ATTR([SKU]),'B') or 
       CONTAINS(ATTR([SKU]),'C') 
       THEN AVG([Total])
       END
     

This is what I have done so far, but not sure how to incorporate the calculated field within the viz

enter image description here

Any suggestion is appreciated.

AnilGoyal

If I understand your problem correctly, proceed like this

Situation-1 You want to work at SKUG level

Create calculation fields each for total/USED/FREE as

SUM(ZN(IF CONTAINS([SKU], 'A') OR CONTAINS([SKU], 'D')
THEN [Total] END))
+
AVG(ZN(IF CONTAINS([SKU], 'B') OR CONTAINS([SKU], 'C')
THEN [Total] END))

Needless to say, please replace [total] by [used] or [free] as applicable

Situation-2 You want to work at higher level of detail instead. In this case you need to decide what you have to do with each of the SKU's group. Let's assume you want to add these. then creating similar fields will do. else replace + in a separate field with your desired operator(!).

Good luck!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Tableau Calculated Field error

Tableau calculated field dates

Tableau calculated field

Error in Tableau calculated field formula

Second Max in Tableau Calculated Field

Tableau/SQL Calculated Field With Grouping

Tableau multiple charts with calculated field

Tableau Calculated Field using FIXED

Using filtered results as field for calculated field in Tableau

Using aggregation within a calculated field in Amazon QuickSight

Calculated Field Within a Query in Access 2016

Tableau calculated field summing up the values

calculated field in tableau dependent on values in column

Tableau Calculated Field COUNTD Single Value

IF part in tableau calculated field is not getting executed

Tableau Calculated Field - across multiple measures

Create a calculated field to count dimension on a condition in Tableau

Sorting of a calculated field fails when using report within a form in Access

Group by calculated field within multiple inner joins / subselects

Tableau: Create a newline between text using a calculated field

Calculated field in tableau to find if the first row is Success or Failure

Get Total Value of Bill Number - Tableau calculated field

Is it possible to count the number of occurrences of a calculated field's result in Tableau?

Regular Expresion in Tableau returns only Null's in Calculated Field

Calculated Field based on an Relation Aggregate with Filter Conditions in Tableau

Tableau calculated field distinct sum of metric base on selected dimensions

Breakout concatenated field into rows not columns within Tableau

Access SQL query that uses a field from one table within where clause to create a calculated field

Tableau. How to get access to a field value of other record in calculated field?