7 Replies Latest reply on Jun 7, 2017 7:28 AM by Simon Runc

# Use Calculated Field to define Opponent team value

Helllo my fellow tableau users.

Based on the DataSource.xlsx file, I need to create a Calculated Field, named as "OpponentName", which represent the Opponent Team for each ID_Match.

Basically, the calculation needs to switch the TeamName.

• ###### 1. Re: Use Calculated Field to define Opponent team value

hi Alejandro,

Interesting problem!...

So the way I did it was to create 2 LoDs...on for the MAX (alphabetically) Team name and one for the MIN.

[MIN Team Name]

{FIXED [Event], [ID Match]: MIN([Team Name])}

[MAX Team Name]

{FIXED [Event],[ID Match]: MAX([Team Name])}

I can then compare one of these to the actual team name, and return the other one!

[Opponent Name]

IF [Team Name] = [MIN Team Name] THEN [MAX Team Name] ELSE [MIN Team Name] END

Hope that does the trick, and makes sense.

1 of 1 people found this helpful
• ###### 2. Re: Use Calculated Field to define Opponent team value

Try this out too, hopefully simpler.

• ###### 3. Re: Use Calculated Field to define Opponent team value

In fact, it is simplier, but I need to have the TeamName column as reference, since I need to retrieve some other columns per IDMatch like Goals and Defenses

• ###### 4. Re: Use Calculated Field to define Opponent team value

Thanks Simon.
Pretty easy.

I couldn't see how easy you resolve the problem.

Thanks

• ###### 5. Re: Use Calculated Field to define Opponent team value

Glad it did the trick...and yes doing it this way does mean that the Opponent Field we created is a "true dimension"....in that is can be used (and will be the same) regardless of the VizLoD. Although as a Aggregated calculation, Hari's version doesn't have this property...I did think it was a clever solution

I couldn't see how easy you resolve the problem.

Just checking...does this mean that you don't understand how/why this works? if not let me know, and I'll be happy to explain what's going on.

• ###### 6. Re: Use Calculated Field to define Opponent team value

Hi Simon.