Forum Discussion
Noobie question about SQL Query
My coworker left me a dataset which is connected to an azure pool and i need to add another column in it.
He used a specific SQL request to load his data and i expected to just edit that request by clicking on the gear near "Source" but it's not here. The only way i could edit his request is to edit the power query request but i've never seen something like this before and i'm pretty sure he didn't code it like this himself :
This is a sample of the whole request,
Is there another way to edit the SQL request without rewriting it in this format ?
I don't know if i'm clear...!
Thank you
5 Replies
- sevenhillsSuper User
Based on the screenshot, the query is auto generated, which is common. FYI, #(lf) .. line feed;
#(tab) ... tab;
Before doing the changes, take a copy and work on it first, to get the solution
Option 1: Editing source in Applied Steps:
Select the query in Power Query Editor
Right side, you see the applied steps. Click the gear icon next to Source and see if you can change the query here.
Option 2: Code mode:
To add another simple column, edit the query in "power query editor" window using "Advanced Editor"...
change
,#(lf)#(tab)#(tab)m.nom_service,
as
,#(lf)#(tab)#(tab)m.nom_service,,#(lf)#(tab)#(tab)t1.newcolname,
See if this works.
Hope this helps!
- JohnnyDaxHelper I
Hi,
Thank you for your answer,
mussaenda double click on source does nothing in my case
sevenhills i don't have the gear icone near source as usual, i suspect he just copy/pasted his request from another PBix, the "show native request" option is also greyed and can't be choosen
I guess i have to rewrite the request properly or edit it in M but that doesn't look easy compared to an SQL request.
- v-jingzhangCommunity Support
Hi JohnnyDax
When you use a custom SQL statement when connecting to a database, the "view native query" option will be disabled. This is by design.
Are you using Power BI Desktop? In my test, I can click the gear icon or double-click on Source step to open the data source connection window. You will see that Power BI will add special characters automatically.
If you cannot open this connection window, you can copy that SQL statement outside and paste it into a Text editor, and remove those special characters. Then it will be easier to edit the SQL statement. After you add the column, copy the new statement into a new query to test the connection first. When you ensure the new table is queried correctly, paste its SQL statement string into the old query's Source step. This should be possible.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. - sevenhillsSuper User
Note: Always the first few steps are the ones where we connect. Then apply the query. if we know the steps, it will be easy to change or edit.
Like I said in previous post, you can see all code in the advanced editor. and change.
Remove all sensitive info and
Please Share the code, I can take a look
Or share the screenshots
Or share the .pbix file.