Create a Parameter
In this example, you create a RoundType parameter so the user can select which Round data to visualize for a player. The RoundName column is added to make the results more user-friendly. For example, QF is mapped to Quarter Final. The new WinsByRound column is added for efficiency, so a match is only considered if it is the same type as the selected RoundType. For example, if the user selects Quarter Final, only Quarter Final type matches are considered.
- Start from the ATPTennisData Project. Select: Projects > ATPTennisData
- Edit the atp_players table.
- Define the parameter:
parameter RoundType allowed_value "All" allowed_value "Quarter Final" allowed_value "Semi Final" allowed_value "Final" default_value "All" type string
- Click Save.
- Edit the atp_matches table.
- Create a RoundName column to make the existing Round abbreviations user-friendly:
column RoundName sql """ case when (Round = 'QF') then 'Quarter Final' else (case when (Round = 'SF') then 'Semi Final' else (case when (Round = 'F') then 'Final' else '' end ) end) end """ type string
- Create a WinsByRound column to only consider round types that match the RoundType parameter:
column WinsByRound sql """ (case when (('atp_players.$RoundType' = 'Quarter Final' and Round = 'QF') or ('atp_players.$RoundType' = 'Semi Final' and Round = 'SF') or ('atp_players.$RoundType' = 'Final' and Round = 'F') or ('atp_players.$RoundType' = 'All')) then 1 else 0 end) """ type int
- Click Save.
- Click Commit.
- Click Deploy.
In the Create the Visualizations tutorial, a new sheet is created for a bar chart visualization. The player name parameter is used as a filter.
IN THIS PAGE