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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors