Những phương pháp tốt nhất khi xây dựng mô hình dữ liệu trong Microsoft Power BI

Chào các bạn,

Trong bài viết hôm nay tôi sẽ chia sẻ một số phương pháp tốt nhất (best practices) khi xây dựng mô hình dữ liệu (data modeling) trong Microsoft Power BI. Các phương pháp này sẽ phát huy tác dụng tốt nhất khi project của các bạn bắt đầu scaling ( dataset có thể mở rộng tới hàng triệu dòng). Nếu dữ liệu của bạn nhỏ (dataset khoảng vài ngàn record) thì có thể bạn sẽ không thấy sự khác biệt nhiều lắm. Microsoft Power BI giúp người dùng có thể dễ dàng để bắt đầu, nhưng để có thể master được Power BI thì bạn thực sự cần hiểu rõ và có kinh nghiệm sử dụng những kỹ thuật cao hơn như M Query và DAX (Data Analysis Expression) language. Trong đó, việc có thể thành thạo về DAX sẽ đòi hỏi ở bạn rất nhiều thời gian để thực hành.

About Author

Xây dựng mô hình dữ liệu tốt (Data Modeling)

Tình huống

  • Một mô hình dữ liệu thiếu hiệu quả sẽ làm chậm tốc độ hiển thị của báo cáo, thậm chí là với một bộ dữ liệu nhỏ.

Đề xuất giải pháp

  • Xây dựng một mô hình nhỏ nhất có thể.
  • Mô hình dữ liệu dạng star schema sẽ hỗ trợ tốt cho việc phân tích sau này.
  • Các mối quan hệ của các bảng dữ liệu phải được xây dựng một cách có mục đích và ý đồ rõ ràng.

Kiểm tra kiến thức của bạn

Mô hình dạng star schema là gì?


Lược đồ hình sao (star schema) bao gồm một hoặc nhiều bảng dữ kiện (fact table) tham chiếu đến bất kỳ số lượng bảng thứ nguyên (dimension table) nào.
Bạn có thể đọc thêm cách định nghĩa của Microsoft về star schema ở đường link bên dưới.
https://docs.microsoft.com/en-us/power-bi/guidance/star-schema?source=docs

Di chuyển việc tính toán tới nguồn dữ liệu

Bối cảnh

  • Bảng dữ liệu có nhiều calculated column với cardinality cao.

Tại sao điều này không tốt?

  • Các calculated column không nén dữ liệu tốt như column thông thường.

Đề xuất giải pháp

  • Thực hiện việc tính toán trong Power Query sẽ giúp kích thước dữ liệu giảm xuống đáng kể.

Kiểm tra kiến thức của bạn

Cardinality là gì?


Cardinality là phép nối giữa hai bảng thể hiện mối quan hệ số giữa các hàng của một bảng với các hàng của bảng còn lại.
Cardinality là cách quản lý mối quan hệ giữa các bảng dữ liệu.
Bạn có thể đọc thêm link bên dưới để hiểu hơn cách tạo và quản lý mối quan hệ giữa các bảng dữ liệu trong Microsoft Power BI.
https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-create-and-manage-relationships

Xóa các bảng và cột dữ liệu không sử dụng đến

Bối cảnh

  • Mô hình chứa các bảng/cột không sử dụng đến cho báo cáo/phân tích hoặc tính toán

Tại sao điều này không tốt?

  • Tăng kích thước mô hình dữ liệu
  • Tăng thời gian tải dữ liệu vào bộ nhớ
  • Tăng refresh time

Tránh việc sử dụng các cột có độ chính xác/cardinality cao

Bối cảnh

  • Mô hình dữ liệu chứa các cột có độ chính xác cao hơn cần thiết. Ví dụ như ngày giờ chính xác tới mili giây, trọng lượng chính xác tới 6 số thập phân.
  • Mô hình dữ liệu chứa các cột với số lượng các giá trị unique cao.

Tại sao điều này không tốt?

  • Độ nén dữ liệu thấp hơn khi độ chính xác/cardinality cao.
  • Tăng thời gian load dữ liệu vào bộ nhớ
  • Tăng refresh time

Đề xuất giải pháp

  • Xóa các cột nếu cần thiết
  • Giảm độ chính xác
  • Chia ngày giờ thành hai cột: ngày và giờ

Tránh sử dụng chuỗi (Strings), sử dụng số nguyên (Integers) nếu có thể

Tại sao điều này không tốt?

  • Chuỗi sử dụng "dictionary encoding", số nguyên sử dụng "run length encoding" - một phương pháp giúp giảm kích thước dữ liệu hiệu quả hơn.

Đề xuất giải pháp

  • Kiểm tra kiểu dữ liệu và đặt về kiểu số nguyên nếu chắc chắn dữ liệu thuộc về kiểu số.

Sử dụng mã định danh số nguyên (Integer Surrogate Keys), tiền-sắp xếp (pre-sorting) mã định danh trước khi load dữ liệu vào mô hình

  • Power BI nén các dòng trong từng cụm, mỗi cụm chứa hàng triệu dòng được nén.
  • Kiểu số nguyên sử dụng Run Length Encoding.
  • Sắp xếp sẽ cực đại hóa khả năng nén khi mã hóa bằng cách giảm độ rộng của dữ liệu trong từng cụm.

Cẩn thận khi sử dụng quan hệ 2 chiều (Bi-Directional Relationships)

Bối cảnh

  • Hầu hết các mối quan hệ của mô hình dữ liệu là 2 chiều

Tại sao điều này không tốt?

  • Sử dụng filters/slicers sẽ khiến quá trình phải xử lý nhiều mối quan hệ và làm quá trình chậm đi.
  • Một vài filter hầu như không tạo thêm giá trị nào cho việc phân tích

Đề xuất giải pháp

  • Chỉ sử dụng quan hệ 2 chiều khi mà bối cảnh thực sự đòi hỏi.

Sử dụng chế độ Summarization mặc định

Bối cảnh

  • Các cột có dữ liệu kiểu số trong mô hình mang tính thuần thông tin ( ví dụ số tài khoản).
  • Chế độ summarization mặc định là phép cộng.

Tại sao điều này không tốt?

  • Power BI sẽ cố gắng xử lý phép cộng khi cột được thả vào visual.
  • Các bảng/ma trận có thể xử lý chậm hơn.

Đề xuất giải pháp

  • Đặt chế độ mặc định là None.

Bạn có muốn kiểm tra kiến thức về Power BI của mình không?

72

Microsoft Power BI Basic Quiz

This is the quiz to test your knowledge on data analysis and Microsoft Power BI. There will be maximum 60 minutes for the test.

Let's do the test and find out your result.

1 / 47

Which data role enables advanced analytics capabilities through reports and visualizations?

2 / 47

Which data analyst task has a critical performance impact on reporting and data analysis?

3 / 47

Which one of the following options is a key benefit of data analysis?

4 / 47

What is the common flow of activity in Power BI?

5 / 47

Which of the following are building blocks of Power BI?

6 / 47

A collection of ready-made visuals, pre-arranged in dashboards and reports is called what in Power BI?

7 / 47

What type of expression do you use to extract data from Microsoft SQL Server?

8 / 47

You're creating a Power BI report with data from an Azure Analysis Services Cube. When the data refreshes in the cube, you would like to see it immediately in the Power BI report. How should you connect?

9 / 47

What can you do to improve performance when you are getting data in Power BI?

10 / 47

What is a risk of having null values in a numeric column?

11 / 47

If you have two queries that have different data, but you want to concatenate the results into one query with all the combined rows, which operation should you perform?

12 / 47

Which of the following selections are not best practices for naming conventions in Power BI?

13 / 47

What does data granularity mean?

14 / 47

What is the difference between a fact table and a dimension table?

15 / 47

Which two functions will help you compare dates to the previous month?

16 / 47

Why would you want to override the default context?

17 / 47

How do you use an inactive relationship in a single measure?

18 / 47

What benefit do you get from analyzing the metadata?

19 / 47

What can be achieved by removing unnecessary rows and columns?

20 / 47

Is it possible to create a relationship between two columns if they are different DATA TYPE columns?

21 / 47

What is the benefit of using a report tooltip?

22 / 47

Which of the following options is not one of the four components in the Q&A visualization?

23 / 47

Do you need to import custom visuals each time you want to use them when you are developing a new report?

24 / 47

Which of the following filters are not available in Power BI reports?

25 / 47

How can you analyze performance of each of your report elements?

26 / 47

Can you use bookmarks to create a slide show in Power BI?

27 / 47

What is a dashboard?

28 / 47

What is one way that reports and dashboards differ?

29 / 47

Where can you configure and set data alerts?

30 / 47

Why are parameters important in Power BI paginated reports?

31 / 47

Power BI paginated reports are created by using which tool?

32 / 47

Power BI paginated reports is an evolved technology that was built from which original tool?

33 / 47

What Power BI feature can give an in-depth analysis of the distribution of data?

34 / 47

 Where are time series charts located?

35 / 47

What visual should be used to display outliers?

36 / 47

What does the AI splits feature do?

37 / 47

Can you access the Q & A feature by using buttons?

38 / 47

Which of the following selections are not features of the Q&A visual?

39 / 47

What does the decomposition tree not enable you to do?

40 / 47

How is the Admin workspace role different from other types of workspace roles?

41 / 47

Which one of the following options is the best description of a workspace?

42 / 47

What feature in Power BI service can you use to troubleshoot the flow of data from its source to its destination?

43 / 47

 Where are dataset-scheduled refreshes configured?

44 / 47

What reserved parameters configure the start and end of where Incremental refresh should occur?

45 / 47

What is the difference between Promotion and Certification when you are endorsing a dataset?

46 / 47

Which function will tell you the username of the person who is signed in to Power BI service?

47 / 47

Where can you test RLS by using different security roles?

Your score is

The average score is 28%

0%

Chia sẻ bài viết

1 thought on “Những phương pháp tốt nhất khi xây dựng mô hình dữ liệu trong Microsoft Power BI”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top