DataWorks DataAnalysis includes a built-in SQL editor with data visualization. After querying a table, you can turn the results into interactive charts — bar, pie, or grouped column — to spot patterns, trends, and outliers without leaving the editor. This tutorial walks through four visualization scenarios using a sample user profile dataset.
Prerequisites
Before you begin, make sure that:
The required data is already processed. This tutorial uses the
ads_user_info_1d_sparktable, which contains basic user profile data processed by DataWorks DataStudio. See Process data.Your account has permission to query the data source you plan to use. To grant permissions, go to Security Center > Security policy > Data query and analysis control > Queryable data source, find the data source, and click Authorization. For details, see Use the data query and analysis control feature.
Visualization scenarios
This tutorial covers the following four scenarios using the ads_user_info_1d_spark table.
| Scenario | Chart type |
|---|---|
| Numbers of registered members in different provinces and cities | Stacked Bar Chart |
| Page view distribution by age range | Pie Chart |
| Page view distribution by gender | Pie Chart |
| Page views by gender and zodiac sign | Grouped Column Chart |
Open SQL Query
Log on to the DataWorks console. In the top navigation bar, select a region. In the left-side navigation pane, choose Data Analysis and Service > DataAnalysis, and then click Go to DataAnalysis. In the left-side navigation pane of DataAnalysis, click SQL Query.
Set up an SQL query file
Create a temporary file.
If this is your first time on the SQL Query page or no file is open, click Create SQL Query.
If a file is already open, click the icon to the right of the existing file name to create a new temporary file.
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 to select a workspace, a compute engine type, and a data source. This tutorial uses a MaxCompute data source.
Query the data
On the configuration tab of the SQL query file, enter the following SQL statement and click the run icon to query the ads_user_info_1d_spark table.
-- If the desired partition is not found, run: show partitions tablename
select * from ads_user_info_1d_spark where dt='Data timestamp';This tutorial queries the dt="20241126" partition.
Visualize query results
After the query completes, click the chart icon on the left side of the query results section to switch to the chart view. To open the chart configuration tab, click the icon in the upper-right corner of the chart.

Each scenario uses the following chart configuration areas:
| Area | Location | Purpose |
|---|---|---|
| Style Settings | Right side of chart configuration tab | Change chart type, customize axis titles |
| Data Settings | Left side of chart configuration tab | Map fields to X-axis, Y-axis, Category, Value, and Split |
Each of the following sections configures one chart from the scenario table above.
Numbers of registered members in different provinces and cities
Chart configuration:
| Setting | Value |
|---|---|
| Chart type | Stacked Bar Chart |
| X-axis field | uid — Aggregate: Distinct Count — Displayed Title: Number of Registered Members |
| Y-axis field | region — Displayed Title: Province |
Steps:
Double-click the chart title and enter a name.
In Style Settings, click Change Chart and select Stacked Bar Chart.
In Data Settings, drag uid to the X-axis area. From the X-axis drop-down list, choose Aggregate > Distinct Count. Drag region to the Y-axis area.

In Style Settings, click Global Settings > Chart Information > Details > Chart Style.
Under X-axis, click Axis Title and set Displayed Title to Number of Registered Members.
Under Y-axis, click Axis Title and set Displayed Title to Province.
Click Save in the upper-right corner.

Result:

Page view distribution by age range
Chart configuration:
| Setting | Value |
|---|---|
| Chart type | Pie Chart |
| Category field | age_range |
| Value field | pv — Aggregate: Sum |
Steps:
Double-click the chart title and enter a name.
In Style Settings, click Change Chart and select Pie Chart.
In Data Settings, drag age_range to the Category area. Drag pv to the Value area and choose Aggregate > Sum from the Value drop-down list.
Click Save in the upper-right corner.

Result:

Page view distribution by gender
Chart configuration:
| Setting | Value |
|---|---|
| Chart type | Pie Chart |
| Category field | gender |
| Value field | pv — Aggregate: Sum |
Steps:
Double-click the chart title and enter a name.
In Style Settings, click Change Chart and select Pie Chart.
In Data Settings, drag gender to the Category area. Drag pv to the Value area and choose Aggregate > Sum from the Value drop-down list.
Click Save in the upper-right corner.

Result:

Page views by gender and zodiac sign
Chart configuration:
| Setting | Value |
|---|---|
| Chart type | Grouped Column Chart |
| X-axis field | gender — Displayed Title: gender |
| Y-axis field | pv — Aggregate: Sum — Displayed Title: pv |
| Split field | zodiac |
Steps:
Double-click the chart title and enter a name.
In Style Settings, click Change Chart and select Grouped Column Chart.
In Data Settings:

Drag gender to the X-axis area.
Drag pv to the Y-axis area and choose Aggregate > Sum from the Y-axis drop-down list.
Drag zodiac to the Split area.
In Style Settings, click Global Settings > Chart Information > Details > Chart Style.
Under X-axis, click Axis Title and set Displayed Title to gender.
Under Y-axis, click Axis Title and set Displayed Title to pv.
Click Save in the upper-right corner.

Result:

What's next
To save a chart permanently and share it, click Save in the upper-right corner.

To create a copy of a chart under a new name (for example, to reuse the same query with a different chart type), click Save As.
To view all charts saved with Save As, click Cards in the left-side navigation pane of DataAnalysis.
