To determine the team of the batter (reverse for pitchers):
IF [Inning Topbot] = "Bot" THEN [Home Team] ELSE [Away Team] END
Identify barrels (although BBS now provides this in a column as well):
IF [Launch Speed] >= 98 AND [Launch Angle] >= 26 - ([Launch Speed] - 98)
AND [Launch Angle] <= 30 + ([Launch Speed] -98)
THEN "Barrel"
ELSE ""
END
To determine At Bats we need to first group the events as follows:
Then create a calculated field:
IF [Events At Bats] = "AB" THEN 1 ELSE 0 END
Same for Hits, On Base, and Plate Appearances:
IF [Events Hits] = "Hits" THEN 1 ELSE 0 END
IF [Events On Base] = "On Base" THEN 1 ELSE 0 END
IF [Events Plate Appearance group] = "PA" THEN 1 ELSE 0 END
From here it is easy to calculate things like:
OBP: SUM([On Base])/SUM([PA])
Batting Average: SUM([Hits])/SUM([AB])
To calculate Slugging we need to calculate total bases first:
IF [Events] = "single" THEN 1ELSEIF [Events] = "double" THEN 2
ELSEIF [Events] = "triple" THEN 3
ELSEIF [Events] = "home_run" THEN 4
ELSE 0
END
Slugging: SUM([Total Bases])/SUM([AB])
Let's double check if this is correct. I ran this for Josh Donaldson and compared it to his ESPN-page:
Now that I know using the raw data from BBS works in Tableau I can start focusing on doing some more interesting analysis and visualizations.
No comments:
Post a Comment