After processing data in DataWorks Data Studio, use SQL Query in DataAnalysis to query a data source and visualize results as charts—no export or separate BI tool required. Four scenarios are covered using user profile data: member rankings by city, page views by age range, page views by gender, and page views by gender and zodiac sign.
Prerequisites
Before you begin, make sure that you have processed the data.
Use cases
This example uses DataAnalysis to visualize and analyze user profile data.
|
Scenario |
Chart |
|
Ranking of registered members by city |
|
|
Age distribution of member page views |
|
|
Gender distribution of member page views |
|
|
Analysis of page views by gender and zodiac sign |
|
SQL Query page
This example uses the SQL Query feature in DataAnalysis.
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Click Go to DataAnalysis to open the Data Analysis page. In the left-side navigation pane, click SQL Query.
Configure the SQL query data source
-
Authorize a Data Source.
You must authorize a data source before using it in Data Analysis. Navigate to the page. Find the desired data source and click Authorization in the Operation column to grant your account the necessary permissions. For more information, see Security Center.
-
Create a Temporary File.
-
Method 1: When you access the SQL Query page for the first time or no SQL file is open in the current window, click Create SQL Query to create a Temporary File.
-
Method 2: If an SQL file is already open, click
to create a Temporary File.
NoteFor more information about creating SQL queries, see SQL query (legacy).
-
-
Select a Data Source.
On the temporary file editing page, click the
icon in the upper-right corner, and select the workspace, engine type, and data source for the current SQL query. In this example, a MaxCompute data source is selected.
SQL statement
On the tab of the temporary file, enter the following SQL statement and click the
icon to query data from the ads_user_info_1d_starrocks table. In this example, the partition is dt='BUSINESS_DATE'.
-- If the desired partition is not found, you can run `show partitions tablename` to check the available partitions.
select * from ads_user_info_1d_starrocks where dt='BUSINESS_DATE';
View query results and edit charts
After the SQL query returns results, click the
button in the left-side navigation pane to visualize them. To edit a chart, click the
button in its upper-right corner.
Ranking of registered users by city
-
Double-click the original title above the chart and enter a new title.
-
Style settings.
Click Style Settings > Change Chart > Stacked Bar Chart on the right side of the page.
-
Data settings.
Click Data Settings on the left side of the page. Set the X Axis column to count (distinct count), and the Y Axis column to region.
-
Drag the uid column to X Axis, and in the X Axis drop-down list, select .
-
Drag the region column to Y Axis.
-
-
Modify the axis titles for the X and Y axes.
Click Style Settings on the right side of the page. In Global Settings > Chart Info, click Details and select the Chart Style tab.
-
Click the axis title for X Axis. In Title Display, configure the X Axis column information and change uid to Registered Members.
-
Click the axis title for Y Axis. In Title Display, configure the Y Axis column information and change region to Province.
-
Click the Save button in the upper-right corner to save the chart.
-
-
Verify the final chart.
Distribution of member visits by age group
-
Double-click the original title above the chart and enter a new title.
-
Style settings.
Click Style Settings > Change Chart > Pie chart on the right side of the page.
-
Data settings.
Click Data Settings on the left side of the page. Set the category column to age_range and the value column to pv.
-
Drag the age_range column to Category.
-
Drag the pv column to Value, and in the Value drop-down list, select .
-
Click the Save button in the upper-right corner to save the chart.
-
-
Verify the final chart.
Distribution of member visits by gender
-
Double-click the original title above the chart and enter a new title.
-
Style settings.
Click Style Settings > Change Chart > Pie chart on the right side of the page.
-
Data settings.
Click Data Settings on the left side of the page. Set the Category column to gender, and the Value column to pv.
-
Drag the gender column to Category.
-
Drag the pv column to Value, and in the value drop-down list, select .
-
Click the Save button in the upper-right corner to save the chart.
-
-
Verify the final chart.
Analysis of visits by gender and zodiac sign
-
Double-click the original title and enter a new title for the chart.
-
Style settings.
Click Style Settings > Change Chart > Grouped Column Chart on the right side of the page.
-
Data settings.
Click Data Settings on the left side of the page and configure the column information:
-
Drag the gender column to X Axis.
-
Drag the pv column to Y Axis, and in the Y Axis drop-down list, select .
-
Drag the zodiac column to Split.
-
-
Modify the axis titles for the X and Y axes.
Click Style Settings on the right side of the page. In Global Settings > Chart Info, click Details and select the Chart Style tab.
-
Click the axis title for X Axis. In Title Display, you can configure the X Axis column information and change gender to Gender.
-
Click the axis title for Y Axis. In Title Display, you can configure the Y Axis column information and change pv to Visits.
-
Click the Save button in the upper-right corner to save the chart.
-
-
Verify the final chart.
Next steps
-
After you finish editing the chart, click the Save button in the upper-right corner to persist and share the results. To create charts of other styles from the processed data, click the Save As button.
-
You can view saved charts by clicking the
icon in the left-side navigation pane of the DataAnalysis page.This icon is the dashboard icon in the left-side navigation pane. Example charts include a column chart showing PV distribution by user and a bar chart showing the ranking of registered users by province.



