To create a new query go to the queries list, click on "New query" on the top right.
On the query editing page you can start by adding a name, description and tags (1)
Next is the area where the SQL query can be written (2), the open wizard button allows to open the db tables browser to see all available tables and fields (3).
At the bottom of this area you can see a preview of the query results.
After creating the query you can add the next step which is the arrow down at (4), this next step can be one of the following categories:
Choice of the type of the visualization for the query result
The scripter step which can run Ruby/Python/C# code on the query result
SQL - which can allow to create a sub query
Date filter - will be presented as part of the actual dashboard and allow to filter the query result by time frame
At the end of the page you can see a preview of the query as it will appear on the dashboard.