Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I have loaded a table of SQL definitions.
Sample record:
| schema_name | view_name | view_definition |
| powerbi | view_fact_program_registration | SELECT p.club_key, p.location_key, p.service_key, p.program_session_key, p.durable_user_key, p.row_is_archived, p.is_unregistered FROM (fact_program_registration p JOIN dim_program_session dp ON ((p.program_session_key = dp.program_session_key))) WHERE (1 = 1); |
On the dashboard, I would like to display the definition in proper SQL format:
SELECT p.club_key,
p.location_key,
p.service_key,
p.program_session_key,
p.durable_user_key,
p.row_is_archived,
p.is_unregistered
FROM fact_program_registration p
JOIN dim_program_session dp ON p.program_session_key = dp.program_session_key
WHERE 1 = 1;
Anyone know of a way to do this? (I'm thinking I may need to create a PowerQuery function?)
Thanks in advance 🙂 Joy
Solved! Go to Solution.
Hi @joyhackett,
AFAIK, current power bi does not support formatting T-SQL strings.
In my opinion, I'd like to suggest your enter 'query editor' to add a custom column to invoke the T-SQL string formatting API that processes and store a formatted string into this custom column.
Regards,
Xiaoxin Sheng
Dear all,
I do have exactely the same issue, but for me in a fabric notebook. I want to document the query in a notebook. Unfortunately the formatting is still like the first screenshot of @joyhackett . Any idea how I can format it in a better way?
Happy about Input 🙂
At the moment I use this:
sql_file_path = 'abfss://xxxx@onelake.dfs.fabric.microsoft.com/xxxx.Lakehouse/Files/silver/views/purchasetransactions.sql'
Hi @joyhackett ,
In DAX you can create a calculated column as follows :
I tried a solution using power query but it did not work in the report view.
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
Thank you.
Your solution will only work for the sample row that I provided. There are 100 rows of SQL view definitions.
However, I see what you are doing with the line breaks, so this puts me on a possible path.
Hi @joyhackett,
AFAIK, current power bi does not support formatting T-SQL strings.
In my opinion, I'd like to suggest your enter 'query editor' to add a custom column to invoke the T-SQL string formatting API that processes and store a formatted string into this custom column.
Regards,
Xiaoxin Sheng
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 35 | |
| 33 | |
| 32 | |
| 27 |
| User | Count |
|---|---|
| 136 | |
| 96 | |
| 77 | |
| 67 | |
| 65 |