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
Custom analyser
With ‘Custom analyser’ feature, Power BI Sidetools users can use external tools built by the…
DAX debugger in Power BI Sidetools
DAX debugger is meant to help Power BI report developers displaying sample data from a…
Manage your external tools easily with Power BI Sidetools
Since the Power BI team allowed to launch external tools from the Power BI desktop…
Easily export to Excel with Power BI Sidetools
While working in Power BI desktop, we often need to export to Excel some data…
Powerful text and file search in Visual Studio Code
As Power BI Sidetools creates files from your report, you are able to search through…
Compare DAX and M formulas in Visual Studio Code
Compare DAX and M formulas in Visual Studio Code is really easy with the help…