jeudi 19 novembre 2020

Implementing a calculated field within my Tableau Viz

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.

Aucun commentaire:

Enregistrer un commentaire