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.

  1. Start from the ATPTennisData Project. Select: Projects Projects > ATPTennisData
  2. Edit the atp_players table.
  3. Define the parameter:
parameter RoundType
   allowed_value "All"
   allowed_value "Quarter Final"
   allowed_value "Semi Final"
   allowed_value "Final"
   default_value "All"
   type string
  1. Click Save.
  2. Edit the atp_matches table.
  3. 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 """
  type string
  1. 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
  1. Click Save.
  2. Click Commit.
  3. 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.