📜 ⬆️ ⬇️

Business Intelligence using MS SQL Server 2008 R2 in a company using 1C accounting systems

In this article, I would like to describe the main stages of building an analytical reporting system using MS SQL Server 2008 R2 in an organization that uses the OLTP accounting system on the 1C platform. This article describes my first experience building a Business Intelligence solution.

image

General input


The company in which I work is engaged in wholesale trade and consists of approximately 30 offices located in regions of Russia. Each office has an information database 1C, in which data on sales are recorded. The organization uses two types of 1C database configurations . One configuration is used in the central office in Moscow, the second - in the branches (in the regions of Russia). Microsoft SQL Server 2008 R2 (SP2) Standard Edition (64-bit) is used as a DBMS supporting the operation of 1C systems. There is no uniform general reference information (NSI). Reference "Products" and some other directories, which are classifiers of products and counterparties, are synchronized by code or other identifier that are stored in 1C systems. One of the main reports used by the organization is the sales report. The existing report on sales allows you to extract data only from the system in which it is formed. The generated reports are uploaded to MS Excel, where they are further processed. In connection with the growth of the company and the emergence of new offices, management has set a task for the IT department to develop a consolidated report that allows automatically obtaining information on sales across all offices of the organization.

Business requirements


The main requirement of the business was the automatic generation of a sales report for all offices of the company. In addition, the report should contain data on the number and amount of sales in the following analytical sections:

The report should allow to impose filters on a sample of any of the analytical sections. As a filter, an arbitrary number of values ​​can be specified. The report should be formed no longer than a minute. Report generation should not significantly affect the performance of 1C accounting systems. The implementation and further maintenance of the report should be minimally costly.
')

Preliminary assessment and decision selection


Based on the input data and requirements, the customer was offered the following solution:

Solution implementation


Stage number 1. Collection of information about data sources in 1C systems. Creating views to get access to the necessary data

Before starting to design the repository, I created views (View) in SQL databases that support the operation of 1C systems. I got two sets of views: a set for the database in the central office (see Fig. 1) and a set for the databases in the branches (Fig. 2). Let me remind you that the structure of the databases in the branches of the organization is the same, but differs from the structure of the database in the central office.

image
Fig. 1. Views in the central office SQL database

image
Fig. 2. Representations in branch office SQL databases

The composition of representations in the central office and branches turned out to be different, as part of the NSI is common and is stored in full in a database at the central office. In particular, we are talking about views:

Creating views in SQL databases allows you to make the solution more universal. For example, when changing the structure of tables in 1C databases, we will not have to make changes to ETL packages, it will suffice to redo the views.

Stage number 2. Development of data warehouse structure. Deploy Data Warehouse

Having completed the first stage, we can easily obtain information on the composition and types of data stored in data sources, and design the structure of the repository. To do this, just look at the types of views columns. For example, the dbo.Clients view is as follows.

image
Fig. 3. Representation of dbo.Clients

Notice that in the dbo.Clients view, there is a ParentId field. With the help of this field, we can later build the Parent-child hierarchy in the multidimensional data model for the “Clients” dimension. A similar field is present in the dbo.Products and dbo.Managers views.

Before you start designing a data warehouse, you need to decide on its layout. There are two data storage schemes - star and snowflake . Both schemes have their pros and cons, and their comparison is beyond the scope of this article. I chose the snowflake scheme, guided by the fact that when moving to SQL Server 2012 and using self-service BI in the future, users will probably find it more convenient to operate with more normalized data from the data store when developing their own data models in PowerPivot for Excel . The structure of the data warehouse developed by me is shown in the following figure.

image
Fig. 4. The structure of the data warehouse

The dim.DimDates (dates), dim.DimOffices (offices), dim.DimRegions (regions of Russia) tables were filled once and do not require automatic updates. The dim.DimOffices table contains the names of the company's offices. The dim.DimDates table contains the date information for the corresponding measurement in the multidimensional data model. The dimension tables contain a surrogate key that serves as the primary key. This is due to the fact that the keys of records in different data sources may overlap.

Stage number 3. Development of a multidimensional data model. Deploy Multidimensional Database

When creating a multidimensional data model, a Data Source View was created in which all tables from the data warehouse were included, except for the stage.FactSales table. This table will only be used to temporarily store sales data before being loaded into the fact.FactSales fact table.

In the Sales cube, two measure groups are implemented (see Figure 5).

image
Fig. 5. Measures

The Cross Products And Projects For Product Matrix measure group provides a many-to-many relationship between the Product and Sales Channel dimensions for the product matrix.

The list of measurements is shown in Figure 6.

image
Fig. 6. Measurements

For the measurement Products, Clients, Managers, the parent-child hierarchy is implemented.

image
Fig. 7. Measuring Goods

To control access to the multidimensional database, the Analists role has been created, which is granted Read and Drillthrough rights for the Sales cube. Drillthrough rights allow users to get a transcript with information about how cell values ​​were calculated in a report.

image
Fig. 8. The Role of Analists

To deploy a multidimensional database on the server, specify the name of the SSAS SQL server instance, the name of the database on the server in the project properties, and click Deploy in the BIDS menu. Connect to the SSAS instance using SMS and see that the multidimensional database was created.

image
Fig. 9. Multidimensional Sales OLAP database

Stage number 4. Development of ETL packages. Deploy ETL packages. Setting up automatic execution of ETL packages

The most time-consuming stage in the design of Business Intelligence solutions is the development of ETL packages. This is due to the fact that data sources, as a rule, have a different structure, and the data stored in them contain errors and have a different format. For example, the gender of an employee in different databases, may be represented by the letters M and F or the numbers 0 and 1, and before loading this data into the repository, it is necessary to perform their cleaning and reduction to a general form. In addition, only data that has been entered or modified since the last download should be updated in the data warehouse. These are only the main difficulties, in fact, they are much more. However, thanks to the SSIS tools, most of these problems can be solved. In my implementation, the data in the dimension tables is updated completely, i.e. new entries are added, and existing entries are overwritten. The fact table is cleared and populated again for a default period of three months. The update depth of the fact table in months is stored in the SSIS package configuration, which is a separate table in the data warehouse.

image
Fig. 10. SSIS packages

Figure 10 shows 4 SSIS packages, the purpose of which is the following:

The logic (Control Flow) of the master package is as follows (see Figure 11).

image
Fig. 11. Package Update DW and Process Sales OLAP

Consider each element of this scheme:

The packages described above are deployed on the SSIS SQL Server instance. To launch the master package automatically on the SQL server, an Update DW and Process Sales OLAP task was created (see Figure 12).

image
Fig. 12. SQL Job to run the SSIS package

To monitor the implementation of the ETL process, the task is configured to notify support staff by e-mail about the completion of the task (see Figure 13).

image
Fig. 13 Setting up a job completion notification by e-mail

Stage number 5. Providing access to multidimensional database

Access to the multidimensional database is provided to employees of the organization through the inclusion of their domain accounts in the Analists role of the multidimensional database using SMS (see Figure 14).

image
Fig. 14. Membership in the role of Analists

Stage number 6. Training staff

For user training, a 15-minute video was recorded, which demonstrated the capabilities of MS Excel, allowing you to connect to a multidimensional database and build a report using the PivotTable Report object. One of the possible report options is shown in Figure 15.


Fig. 15. Example of a PivotTable Report in Excel

findings


Customer requirements were fully implemented. Beta testing was carried out by key users of the company who generate daily sales reports. In their report, key users described the created solution as very convenient, fast and sufficient to conduct a comprehensive analysis of sales. To evaluate the solution I cite some numbers:

Source: https://habr.com/ru/post/212349/


All Articles