Power BI Custom Connector: Build a Module's Lineage View

Power BI Custom Connector: Build a Module's Lineage View

What

The scenario we are dealing with is as follows:

Power Query connectors do not support Lineage View in Visual Studio Code, unlike in Power BI. I have undertaken the task of restructuring an old project: a massive .pb file comprising 2091 lines.

No alt text provided for this image
The old project has a long code

WHY

In Power BI custom connector projects, comprehending the data flow from the data source to its destination can pose a challenge:

My new project consists of more than 100 modules, and these modules are interconnected using Extention.LoadFunction.

No alt text provided for this image
Split to many modules

  • Questions like "What happens if I change this module?", "How many modules I already create?", "Which module did not use any more? ", "Why this module did not work? " can be hard to answer.

HOW

I would like a clear visual representation of the flow. For instance, ABCProject is linked to module.02_main, and module.02_main is connected to module.05_navigator, and so forth.

No alt text provided for this image
the flow

To begin, I must generate metadata within the code to establish the connections between modules. I will utilize the comments //Lineage and //EndLineage as reference markers, implementing this for each .pb and .pqm file.

...
//Lineage
? ? module.05_navigater = Extension.LoadFunction("module.05_navigater.pqm"),
//EndLineage
...        


... invokes the Power BI query to retrieve the file's metadata. I have built a function for code parsing. ?The following M code:

let
? ? Source = (Parameter1 as binary) => let
? ? Source = Csv.Document(Parameter1,[Delimiter=";", Columns=1, Encoding=65001, QuoteStyle=QuoteStyle.None]),
? ? #"Trimmed Text" = Table.TransformColumns(Source,{{"Column1", Text.Trim, type text}}),
? ? #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Column1", Text.Clean, type text}}),
? ? #"Added Index" = Table.AddIndexColumn(#"Cleaned Text", "Index", 0, 1, Int64.Type),
? ? FilteredHeaderRows = Table.SelectRows(#"Added Index", each ([Column1] = "https://Lineage")),
? ? FilteredBottomRows = Table.SelectRows(#"Added Index", each ([Column1] = "https://EndLineage")),
? ? IsRef = Table.RowCount(FilteredHeaderRows) > 0,
? ? Top = FilteredHeaderRows{0}[Index],
? ? Bot = FilteredBottomRows{0}[Index],
? ? #"Kept Range of Rows" = Table.Range(#"Added Index",Top+1,Bot-Top-1),
? ? #"Removed Other Columns" = Table.SelectColumns(#"Kept Range of Rows",{"Column1"}),
? ? #"Inserted Text Between Delimiters" = Table.AddColumn(#"Removed Other Columns", "Text Between Delimiters", each Text.BetweenDelimiters([Column1], """", """"), type text),
? ? #"Renamed Columns" = Table.RenameColumns(#"Inserted Text Between Delimiters",{{"Text Between Delimiters", "Node"}}),
? ? #"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns",{"Node"}),
? ? result = if IsRef then #"Removed Other Columns1" else #table({"Node"}, {{""}})
in
? ? result
in
? ? Source        

...utilizes the function to obtain the linkage among files. You'll invoke the custom function on the files within the custom PB project using Folder.Files(..). Here is the resulting output:

No alt text provided for this image

I need the flattening of hierarchies with multiple parents and children. Using the code from www.thebiccountant.com/ makes this process quite straightforward. Here is the resulting output:

No alt text provided for this image

Add columns for Level 1, Level 2, and so on, to the Decomposite Tree. Here's the configuration of the visual in Power BI:

No alt text provided for this image

However, we can achieve an even better outcome.?In the example pbix file I’ve uploaded?here, I’ve created a function to get the content of each files. I won’t go through the M code because there’s nothing interesting in it, but the end result is a report that allows you to drill through to the file's content:

No alt text provided for this image

One last thing to point out regarding these examples is that the Decomposite Tree is not build for Lineview. It will not display accurately if a module is utilized by many other modules.

C?ng Nguy?n

Tech is easy, people are challenging

1 年

Thank Ngh?a. Your post inspired me to learn about #datafabric #dbt #flask ... ;)

回复

Dev Mcode trên VSC lun h? anh ??????

要查看或添加评论,请登录

Nghia Tran的更多文章

  • Microsoft Fabric Licensing Calculator

    Microsoft Fabric Licensing Calculator

    Updated image Full Link

  • RLS in Microsoft Fabric Dataset

    RLS in Microsoft Fabric Dataset

    Some limitations of Direct Lake in its current Public Preview state include the inability to create row-level security…

  • Real-time Analytics: Streaming SQL Server Data to Fabric using Debezium

    Real-time Analytics: Streaming SQL Server Data to Fabric using Debezium

    Introduction/What This article draws a method to stream data in real-time from SQL Server to Fabric using Debezium…

  • DBT in Microsoft Fabric: MY JOURNAL

    DBT in Microsoft Fabric: MY JOURNAL

    Update 20231114: Git Installs on Runtime 1.2 (link) - thanks venkims fromMS.

    2 条评论
  • Microsoft Fabric With dbt

    Microsoft Fabric With dbt

    UPDATE 2023-06-28: You can find more complete detailed and optimized examples for this content in the DBT in Microsoft…

  • Dynamic format strings in Power BI

    Dynamic format strings in Power BI

    V?n ?? Các báo cáo tài chính c?a Vi?t Nam th??ng có con s? r?t l?n t? ??n vài nghìn t?, do v?y h? th??ng có nhu c?u…

    1 条评论
  • Load Azure to Snowflake by dbt

    Load Azure to Snowflake by dbt

    V?n ?? Sau khi d? li?u ???c trích xu?t t? các Datasource và ???c ?áp xu?ng Azure Data Lake. Ta c?n ??a d? li?u t? Lake…

    1 条评论
  • Camera AI và Power BI ?? theo d?i k? n?ng c?a nhan viên real-time.

    Camera AI và Power BI ?? theo d?i k? n?ng c?a nhan viên real-time.

    M?c tiêu Data Team xay d?ng 1 ??a ?i?m ?? nhan viên có th? xem th?ng tin k? n?ng mà mình ?? h?c khi tham gia các l?p…

  • Auto refresh data in Power BI Desktop

    Auto refresh data in Power BI Desktop

    Power BI Desktop là phiên b?n Free cho phép chúng ta k?t n?i/x? ly/ v? bi?u ?? chia s? file ??n cho ng??i khác. Nh?ng…

    3 条评论
  • Data Governance: Audit Power BI Tenant Settings

    Data Governance: Audit Power BI Tenant Settings

    Gi?i thi?u Bài vi?t này s? cung c?p cho b?n h??ng d?n t?ng b??c v? cách l?y + ki?m tra các c?u hình d?ch v? Power BI và…

社区洞察

其他会员也浏览了