DataWorks DataAnalysis includes a data visualization tool that lets you turn SQL query results into charts. This topic walks through an example that queries user profile data and produces four charts covering member registrations, page views by age, page views by gender, and page views by gender and zodiac sign.
Prerequisites
Before you begin, make sure you have:
Processed the sample data in DataWorks DataStudio. This example uses the basic user profile data produced by that tutorial
Access to the data source you want to query (if not, complete step 1 in Configure a data source for a SQL query to request authorization before proceeding)
Data analysis scenarios
The following four scenarios are covered in this example, all based on member user profile data.
| Scenario | Chart |
|---|---|
| Numbers of registered members in different provinces and cities | (chart image) |
| Distribution of page views of members in different age ranges | (chart image) |
| Distribution of page views of members by gender | (chart image) |
| Numbers of page views of members counted by gender and zodiac sign | (chart image) |
Go to the SQL query page
Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose Data Analysis and Service > DataAnalysis. On the page that appears, click Go to DataAnalysis. In the left-side navigation pane of the page that appears, click SQL Query.
Configure a data source for a SQL query
Complete the following steps before running a query.
Grant your account access to the data source. Go to Security Center and choose Security policy > Data query and analysis control. On the Queryable data source tab, find the data source you want to query and click Authorization in the Actions column. For more information, see Use the data query and analysis control feature.
Create a temporary file for the SQL query.
If no SQL query file is open on the SQL Query page, click Create SQL Query in the right-side area.
If an existing SQL query file is already open, click the
icon to the right of the file name.
For more information about SQL query files, see SQL query.
Select a data source. On the configuration tab of the SQL query file, click the
icon in the upper-right corner. Select a workspace, a compute engine type, and a data source. This example uses a MaxCompute data source.
Write SQL statements
On the configuration tab of the SQL query file, enter the following SQL statement and click the
icon to run the query against the ads_user_info_1d_odps table. Replace <data-timestamp> with the partition date you want to query (for example, 20241126).
-- If the partition is not found, run "show partitions tablename" to list available partitions.
select * from ads_user_info_1d_odps where dt='<data-timestamp>';View query results and modify charts
Visualize the query result. After the query completes, click the
icon on the left side of the query result section to switch to chart view.
Modify the chart. Click the
icon in the upper-right corner of the chart to open the chart configuration panel.
What's next
To permanently save your chart and share it, click Save in the upper-right corner. To save it as a new chart with a different type, click Save As.
To view charts you've saved, click Cards in the left-side navigation pane of the DataAnalysis page.