Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cmengel
Advocate II
Advocate II

Build a data profile query from list of table names

Hi!

 

I'd like to build a query that creates a table based on the Table.Profile function.

 

I'd like to 'feed' the function a list of table names and then add a custom column to contain the table name itself.

 

The resulting table enables me to generate some high-level data quality / data integrity visuals in Power BI.

 

Here's the code I have so far, and I'm a bit stuck:

let
TABLE_NAMES = {"DIM_DATE", "DIM_HEADER", "DIM_WO_GEOGRAPHY_CN", "DIM_EQUIPMENT_CN", "DIM_SEGMENT", "DIM_WORKORDER_EQUIPMENT_CN"},
Source = Table.Profile(TABLE_NAMES),
#"Added Custom" = Table.AddColumn(Source, "TABLE_NAME", each TABLE_NAMES),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Count", Int64.Type}, {"NullCount", Int64.Type}, {"DistinctCount", Int64.Type}})
in
#"Changed Type"

 

This community is the greatest!

 

Thanks in advance for your help and suggestions.

 

Warm regards,

Chris

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Not sure if this is what you need, but you can use this expression to get the profile of all tables in your model.  Note the first filter removes the name you give this query (to avoid a circ reference).  You could further filter it to only include the tables you want.

 

let
    Source = #shared,
    #"Converted to Table" = Record.ToTable(Source),
    #"Added Custom1" = Table.AddColumn(#"Converted to Table", "Custom", each Value.Is([Value], type table)),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each [Name] <> "ThisQuery"),
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each ([Custom] = true)),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows1", "Profile", each Table.Profile([Value])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Value", "Custom"}),
    #"Expanded Profile" = Table.ExpandTableColumn(#"Removed Columns", "Profile", {"Column", "Min", "Max", "Average", "StandardDeviation", "Count", "NullCount", "DistinctCount"}, {"Column", "Min", "Max", "Average", "StandardDeviation", "Count", "NullCount", "DistinctCount"})
in
    #"Expanded Profile"

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
mahoneypat
Microsoft Employee
Microsoft Employee

Not sure if this is what you need, but you can use this expression to get the profile of all tables in your model.  Note the first filter removes the name you give this query (to avoid a circ reference).  You could further filter it to only include the tables you want.

 

let
    Source = #shared,
    #"Converted to Table" = Record.ToTable(Source),
    #"Added Custom1" = Table.AddColumn(#"Converted to Table", "Custom", each Value.Is([Value], type table)),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom1", each [Name] <> "ThisQuery"),
    #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each ([Custom] = true)),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows1", "Profile", each Table.Profile([Value])),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Value", "Custom"}),
    #"Expanded Profile" = Table.ExpandTableColumn(#"Removed Columns", "Profile", {"Column", "Min", "Max", "Average", "StandardDeviation", "Count", "NullCount", "DistinctCount"}, {"Column", "Min", "Max", "Average", "StandardDeviation", "Count", "NullCount", "DistinctCount"})
in
    #"Expanded Profile"

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi Pat!

 

Well, I thought I was in the clear because I didn't get the error message, but now I have a new issue:

cmengel_0-1636574813478.png

 

The query steps look like they're working, but there's no distribution information.  Additionally, after I hit close and load, I end up with an empty table.

cmengel_1-1636574917733.png

Any thoughts on why that might be the case?

Me too. any resolusions? 

thanks 

Hi Pat!

 

Well, I thought I was in the clear because I didn't get the error message, but now I have a new issue:

cmengel_0-1636574813478.png

 

The query steps look like they're working, but there's no distribution information.  Additionally, after I hit close and load, I end up with an empty table.

cmengel_1-1636574917733.png

Any thoughts on why that might be the case?

Hi Pat!

Thanks so much for the prompt reply.

This is a really interesting approach and certainly moves me toward my objective.

 

When I step through the Applied steps, specifically Filtered Rows to Filtered Rows1, it throws an 'Unexpected Error":

 

Filtered Rows Step: (all is well)

cmengel_0-1636557236150.png

 

Filtered Rows1 step: (suddenly not well)

cmengel_1-1636557322937.png

 

The issue was on my end.  I rearranged a few of the steps to filter right after the table is created and that resolved my issue.  This is an excellent pattern!

 

Thanks again for the quick response and very slick approach!  Love it!

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors