4 Replies Latest reply on Oct 21, 2018 9:52 AM by Milankumar Patel

# Convert SPSS Syntax to Tableau Calculation

Hi,

I want to convert below SPSS Syntax to Tableau Calculated field so I can use in my chart creation view.

Basically, what it does, VAR_1 has 3 options. Below syntax takes, First value of each variable in VAR_* series and creates a new variable named "VARMRV".

****************************************************************************************************************

IF  (VAR_1 = 1) VARMRV=1.

IF  (VAR_2 = 1) VARMRV=2.

IF  (VAR_3 = 1) VARMRV=3.

IF  (VAR_4 = 1) VARMRV=4.

IF  (VAR_5 = 1) VARMRV=5.

IF  (VAR_6 = 1) VARMRV=6.

IF  (VAR_7 = 1) VARMRV=7.

IF  (VAR_8 = 1) VARMRV=8.

IF  (VAR_9 = 1) VARMRV=9.

IF  (VAR_10 = 1) VARMRV=10.

IF  (VAR_96 = 1) VARMRV=96.

EXECUTE.

* Define Variable Properties.

*VARMRV.

VARIABLE LABELS  VARMRV 'Top 1 Data from VAR Series'.

VALUE LABELS VARMRV

1.00 'Reason1'

2.00 'Reason2'

3.00 'Reason3'

4.00 'Reason4'

5.00 'Reason5'

6.00 'Reason6'

7.00 'Reason7'

8.00 'Reason8'

9.00 'Reason9'

10.00 'Reason10'

96.00 'Reason11 '.

EXECUTE.

*********************************************************************************************************

I want to create same thing in Tableau. How can i do this?

• ###### 1. Re: Convert SPSS Syntax to Tableau Calculation

What I understand from this is, You want to Create VARMRV Like This, I assume that First Value is always 1

If Var1={MIN(Var1)} Then 1

ELSEIF

Var2={MIN(Var2)} Then 2

ELSEIF

Var3={MIN(Var3)} Then 3

.

.

.

ELSEIF

Var96={MIN(Var96)} Then 96

END

Thanks

Deepak

• ###### 2. Re: Convert SPSS Syntax to Tableau Calculation

Hi Deepak,

I will give it a try and let you know. How would I give those new values a name?

Regards,

Milan

• ###### 3. Re: Convert SPSS Syntax to Tableau Calculation

When You Createa  New Calculated Field. Name it VARMRV and write above formula

• ###### 4. Re: Convert SPSS Syntax to Tableau Calculation

Hi Deepak,

When I tried to create the VARMRV using the method said above, The numbers were not matching with SPSS. So I tried a different approch and created 5 different variables in SPSS. 1. Tenure_ALL (having all date periods) 2. Tenure_3m (Less than 3 month) 3. Tenure_6m (Less than 6 month) 4. Tenure_12m (Less than 12 months) 5. Tenure_G12m (More than 12 months).

I want to create a filter like a dropdown list from this 5 variables. Like when Someone select less than 3 month from dropdown, the data displayed on chart will be filtered to display less than 3 month data. just add more info here, chart will be created using different variables, I also want to create a filter using above variables.

I tried creating a parameter first, than created another calculated field aligned to parameter. But I am not able to put it as a filter.

Any help on this will be much appreciated.