Different Users Subscribe to the Same Report with Different Data Content
Requirement Scenario
A data analyst from a large national chain store, in a report, displays the daily operational status of each city branch of the company. This report needs to be shown to everyone in the company, ensuring that each city user can only view the daily operations of the city they oversee.
Solution
Data analysts create datasets and control the data content through user attributes, ensuring that different users see different data content, and the analysis reports built on this basis also display different content. The HENGSHI SENSE system is quite flexible in controlling data content. This article introduces two commonly used methods for controlling dataset content display.
Target Audience: Data Analysts (individuals with a data analysis role) Applicable Conditions: The datasets in the app meet the following criteria:
- All datasets in the app are newly created datasets within the app, not involving datasets from the data mart.
- The data model setting in the app is set to either the app author or the dataset author.
Control Data Content Display During Data Creation
Data analyst Xiao Wang creates an analysis app and sets the app mode to either the app owner or the dataset owner.
Xiao Wang creates datasets, including local files, data connections, SQL query datasets, and derived datasets, and requires that users can only view data from their own city. Xiao Wang notices that there is a region field in the dataset that corresponds with the user attribute city, so Xiao Wang uses the user attribute city to match the region field in the data when creating the dataset, ensuring that users can only see data that matches their address. The example demonstrates the use of the user attribute city to match the region field in the dataset creation process for data connections and SQL query datasets; other datasets can refer to this setup.
Analyst Xiao Wang uses the created datasets to create reports. Since Xiao Wang's user attribute city is Tianjin, the related reports only show data from Tianjin.
When sharing the reports with other users, as expected, User A's city attribute is Shaanxi, and the report they view only shows operational data from Shaanxi. User B's city attribute is Chengdu, and the report they view only shows data from Chengdu. User C's city attribute is Nanjing, and the report they view only shows data from Nanjing.
From the above steps, it can be seen that using user attributes to control data content during data creation (the example demonstrates the dataset creation process, which also includes adding fields, atomic indicators, parameters, etc.) can achieve the effect of displaying different data content to different users.
Control Data Content Display After Data Creation
Analyst Xiao Wang creates an app and sets the data schema to app author or dataset author.
Xiao Wang creates datasets, including local files, data connections, SQL query datasets, and derived datasets (without using user attribute filters during the data creation process).
Xiao Wang uses the datasets for modeling and analysis, creating daily operational reports on company sales, collections, and customer-related information, as shown below, where all regional information can be seen.
This report requires that users from different cities can only view information from their own city. Therefore, Analyst Xiao Wang controls the data content in App Settings -> Permissions Control. The region information in the data is matched with the user attribute city, and users can only view data that matches their user attribute city, i.e., information related to their own city.
5. After setting up the permission control, Analyst Xiao Wang checks his report and can only see the operational data for the city of Tianjin, which meets expectations. 6. Share the completed report with other colleagues for viewing. Colleague A's city attribute is Shaanxi, and the report they view only shows operational data for the Shaanxi region. User B's city attribute is Chengdu, and the report they view only shows relevant data for the Chengdu region. User C's city attribute is Nanjing, and the report they view only shows relevant data for the Nanjing region. 7. From the above examples, it can be seen that after the data is created, permission control can be applied to the data so that different users can view different data content.
Summary:
This practice introduces two methods for controlling data display. The first method is performed during the data creation process, and the second is after the data creation. The first method is more flexible but also has limitations. In the example above, if the user did not record the city in the attribute city
, the first method would not be able to control the display of data content. The second method has strong universality. By selecting user information, different data content can be set for different users, allowing users from different cities to view operational data for their own city.