Visualize your SQL database schema within Power Query
Often, we need to look for a table or for a specific column in the database. Do you know it’s possible to create a simple query to visualize your database schema within Power Query ? Very few steps for great results.
How to display database schema (first method with data preview)
- Add a blank query and name it ‘dbScheme’
- Open the advanced editor
- Copy this code and close advanced editor
let
Source = Sql.Database( yourserver , yourdatabase ),
#"Filtered Rows" = Table.SelectRows(Source, each ([Kind] = "Table")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Schema", "Item", "Kind"})
in
#"Removed Columns"
Click on a table and see a sample of content

How to display database schema (second method)
Here is the whole query :
let
Source = Sql.Database("yourserver", "your database", [Query="
SELECT
c.TABLE_NAME as 'Table', c.COLUMN_NAME as 'Column'
FROM INFORMATION_SCHEMA.COLUMNS c
INNER JOIN
(SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
GROUP BY COLUMN_NAME
HAVING COUNT(*) > 1
) dupes
ON dupes.COLUMN_NAME = c.COLUMN_NAME
", CommandTimeout=#duration(0, 0, 1, 0)]),
#"Sorted Rows" = Table.Sort(Source,{{"TABLE_NAME", Order.Ascending}})
in
#"Sorted Rows"
How to (third method)
Phil Seamark method : Diagram your Database Tables using Power BI
See also how to document M functions : M functions documentation within Power Query
Manage your external tools easily with Power BI Sidetools
Since the Power BI team allowed to launch external tools from the Power BI desktop ribbon, several tools became available. Do you know you can…
Easily export to Excel with Power BI Sidetools
While working in Power BI desktop, we often need to export to Excel some data sharing with customers or colleagues. Once shared, we don’t want…
Powerful text and file search in Visual Studio Code
Text and file search in Visual Studio Code is really powerful. There are different ways to search and replace. The only difficulty you will meet…
Compare DAX and M formulas in Visual Studio Code
Compare DAX and M formulas in Visual Studio Code is really easy with the help of Power BI Sidetools.As it is possible to transfer DAX…
Translations life cycle management
Translations life cycle management must be considered seriously as soon as we decide to translate Power BI reports. Translating a report in several languages takes…
Automatic translation of visuals labels
Automatic translation of visuals labels in Power BI reports is possible using conditional formating, Tabular Editor and an Excel template. At the moment, labels are…