Power BI - Write Data to SQL

  Рет қаралды 61,877

BI Elite

BI Elite

Күн бұрын

UPDATED: See this video for a better technique to write back multiple rows: • BULK Write Back to SQL...
In this Power BI tutorial, learn how to write your data back to a SQL database! I will show you how to query a web API and then store the results in a SQL Server database which you can then report off of! You can even set up multiple datasets on scheduled refresh to push your data to SQL every hour or even every 30 minutes!
Elite Power BI Consulting:
bielite.com
To enroll in my introductory or advanced Power BI courses:
training.bieli...
Connect with me on Twitter!
/ powerbielite

Пікірлер: 99
@BIElite
@BIElite 3 жыл бұрын
UPDATED: See this video for a better technique to write back multiple rows: kzbin.info/www/bejne/jZismaZ8bNB4oKs
@MTUK1981
@MTUK1981 11 ай бұрын
Great info. Tried to look for a simple explanation of Power BI data to SQL Server and you've done it! Thanks 🙂
@dannyaguirre2309
@dannyaguirre2309 4 жыл бұрын
This is awesome !!! I just created process to read SharePoint Online Lists and sink the data to the SQL Data Warehouse. I did have to modify the code as I need to run an insert for each row however Text.Combine() was the unsung hero. Passing the sql scripts as one large text tuple set, with a group by transformation. Thanks for explaining this !!!
@MacPaulos
@MacPaulos 3 жыл бұрын
Hey Danny, I'm very interested in the steps you did for this. This is exactly what I'm trying to do now :). Thanks for letting me know it's possible
@JackOfTrades12
@JackOfTrades12 4 жыл бұрын
I was literally trying to do this using workaround R script (which I'm not good at). I can't believe this is so easy.... Thank you for your video!
@BIElite
@BIElite 4 жыл бұрын
Good to hear, Jon! I've also tried with Python and R lol
@JackOfTrades12
@JackOfTrades12 4 жыл бұрын
@@BIElite have you found any performance difference?
@thiagofraletti4220
@thiagofraletti4220 3 жыл бұрын
Amazing. This approach enable the usage of Power Query to one of the most useful cases of ETL. Thanks!
@BIElite
@BIElite 3 жыл бұрын
I agree! It's lightweight and free.
@cristian.angyal
@cristian.angyal 4 жыл бұрын
WOOW! This is Pure Gold! Thanks for sharing ! I'm already thinking of at least two use-cases I have:)
@BIElite
@BIElite 4 жыл бұрын
Great to hear, Cristian! I'm looking for other datasets to use this for as well.
@nehashahpatel1741
@nehashahpatel1741 3 жыл бұрын
What a mastermind trick Parker you show.. Millions Thanks
@tommynguyen4253
@tommynguyen4253 4 жыл бұрын
Wow, this is very eyes-opening. I am wondering how we can insert multiple values at the same time? The drill down took only one row at a time.
@BIElite
@BIElite 4 жыл бұрын
Good point, Tommy. You can get around this by converting your SQL column to a list and then using the Text.Combine() function to concatenate all of your rows.
@brijendraydv
@brijendraydv 4 жыл бұрын
@@BIElite Hi,thanks for the tip but it throws me error after list that cannot convert list to type text when i want to insert more than one record.Is it possible to make to more clear how to insert more than 1 record,thanks
@noyraz
@noyraz 4 жыл бұрын
its will be great to know how can we insert to sql more than 1 row
@brijendraydv
@brijendraydv 4 жыл бұрын
@@noyraz indeed ,looking forward for it😉
@DreeKun
@DreeKun 4 жыл бұрын
I did it like this: let fxListGenerate = () => let Source = List.Generate( ()=> [Result= try fxRunSQL(0) otherwise null, x = 0], each [Result] null, each [Result = try fxRunSQL([x]+1) otherwise null, x =[x]+1], each [Result]), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandTableColumn(your column names), #"Removed Duplicates" = Table.Distinct(#"Expanded Column1", {primary key column}), in #"Removed Duplicates" fxRunSQL = (x as number) => let Source = Sql.Database(server name, database name), INSERT = Value.NativeQuery(Source, #"API Call and INSERT Data"{x}[Custom]) in INSERT in fxListGenerate Although it works, it isn't very efficient because it just selects all tables, combines them and then removes the duplicates. Now that I saw this, I'm going to try Parker's advice.
@kirisko3067
@kirisko3067 3 жыл бұрын
Very very helpful Thank you
@Tegarcahya
@Tegarcahya 4 жыл бұрын
I'm using Oracle as a database and I get errors like this "Native queries aren't supported by this value." any suggestion?
@mediocrestuff2783
@mediocrestuff2783 3 жыл бұрын
Hey did you get any solution for this error?
@Bananathan25
@Bananathan25 3 жыл бұрын
Hi, thank you so much for this. I can get the query to run, however it only runs for the first row in my dataset. Do you know how to get the Native query to run for each row in the dataset?
@Bananathan25
@Bananathan25 3 жыл бұрын
In case anyone comes across this, I've got it: Instead of right clicking and drilling down on the column, add this line of M code after the AddSQLColumn part: SQL = Text.Combine(#"Added Custom"[SQL],"#(lf)")
@tenaciousdata9200
@tenaciousdata9200 4 жыл бұрын
This is a good one! Thank you Parker!
@BIElite
@BIElite 4 жыл бұрын
No problem! Thanks for the comment
@zacharydrake7925
@zacharydrake7925 3 жыл бұрын
Do you know how I can expand this to multiple rows on a tabel? Currently only getting 1 row to write when I need it to look through a number of rows.
@BIElite
@BIElite 3 жыл бұрын
Hi Zachary, see my latest video from today! It shows how to insert multiple records in a SQL db.
@louism.4980
@louism.4980 8 ай бұрын
This is fantastic, thank you! :)
@timvollman9017
@timvollman9017 3 жыл бұрын
Which statement actually pulls data from the API data source
@kaushmat
@kaushmat 4 жыл бұрын
This is very useful. 😲 1 question. In this example, you are writing back the data as part of a scheduled refresh process. Can it be done in a non-scheduled manner (i.e., the user opens the dashboard at her own convenient time, and wants to write certain data back to SQL through Power BI). Is this possible?
@BIElite
@BIElite 4 жыл бұрын
Really interesting question. Yes, definitely. Don't set this up for scheduled refresh, and instead just refresh the dataset manually. If your end user doesn't have access to the workspace, you can leverage Power Automate to refresh the dataset via button click in your Power BI report.
@saadnageeb4633
@saadnageeb4633 2 жыл бұрын
Wonderful, its a very helpful Idea, Thanks a lot
@padreloco9733
@padreloco9733 4 жыл бұрын
Thanks for the video! Amazing. One quick question: I have created a dataflow in power bi. A colleague of mine needs this dataflow to feed its PIMS. Is there I way I can pass her this dataflow? Let's say like exporting this dataflow to MySQL? Your Idea will be much appreciated. Thanks.
@yoismelperez2744
@yoismelperez2744 2 жыл бұрын
Has anyone tried this and works in the Desktop but not in the service? I have an example that works fine in both sides but a new report I am working on is writing to SQL from the Desktop but not in the service, so just checking if we know of any limitations on doing this?
@JonasArnout
@JonasArnout 4 жыл бұрын
Interesting! Why would you not use MS Flow for this?
@user-hu7ov6fi9y
@user-hu7ov6fi9y 4 жыл бұрын
Hey Parker, thanks a lot for this video! Very informative.
@michamuszynski6832
@michamuszynski6832 4 жыл бұрын
Hi! this is very useful solution. BTW which of the dataset is your source for the raport? As I know there is no possibility to use multiple datasets for one report.
@BIElite
@BIElite 4 жыл бұрын
Dzień dobry Michał! Not sure exactly what you mean in this question. Could you elaborate?
@michamuszynski6832
@michamuszynski6832 4 жыл бұрын
@@BIElite I have understood that you have build three datasets 'DataInsert No 1,2,3' to insert data into a data base. Is your report refreshed once per hour as well? How are you able to connect three datasets to one report.
@tejasbrahmbatt5344
@tejasbrahmbatt5344 4 жыл бұрын
Hi Parker, How can I delete the current SQL Table before and then bulk insert all the data from Power Query ? Please help..!!
@Rafian1924
@Rafian1924 3 жыл бұрын
Hi, How do we do it if we have 1000 rows in a dataset table.
@zxuan
@zxuan 3 жыл бұрын
This is great! However it only works in Import data mode
@deniseyu9015
@deniseyu9015 2 жыл бұрын
It's really cool and amazing! Excellent tips
@HachiAdachi
@HachiAdachi 4 жыл бұрын
Ah-Mazing! 😲 Thank you, Parker!
@BIElite
@BIElite 4 жыл бұрын
Haha thanks Hachi!
@yudhinugrahariyansyah9432
@yudhinugrahariyansyah9432 4 жыл бұрын
i have multiple row to insert , it can work with text combine the list , but i got error if the data has single quotation mark in the text. any advice ?
@plgmgua
@plgmgua 4 жыл бұрын
this is crazy good!!! thanks alot!
@BIElite
@BIElite 4 жыл бұрын
No problem, Peter!
@ducthinhvu2167
@ducthinhvu2167 2 жыл бұрын
how did you do it can you share with me , thank you
@vladimir.v.saveliev
@vladimir.v.saveliev 4 жыл бұрын
Thanks!!! It's amazing!
@RahulNegiworld
@RahulNegiworld 4 жыл бұрын
When I'm using INSERT I'm getting error i.e. Expression.Error: We cannot convert a value of type Table to type Text. Could you please suggest correct solution? Thanks in advance!
@didijaba
@didijaba 4 жыл бұрын
I had same problem, you need to turn AddSQL column to list and then use Text.Combine with space as separator. After that it works. AddSQLColumn = Text.Combine(#"Changed Type"[AddSQLColumn]," ")
@samwong777
@samwong777 4 жыл бұрын
@@didijaba After the AddSQLColumn step, I turned my SQL Column into a list. So does the Text.Combine step come in after I turn the SQL Column into a list? And what text am I combining?
@didijaba
@didijaba 4 жыл бұрын
@@samwong777 #"Create SQL expression" = Table.AddColumn(#"Changed Type3", "AddSQLColumn", each "IF EXISTS (SELECT * FROM tblHops_SatnoOpterecenje WITH (UPDLOCK) WHERE tblHops_SatnoOpterecenje_ID = '" & [tblHops_SatnoOpterecenje_ID] & "')#(lf)SELECT * FROM tblHops_SatnoOpterecenje#(lf)ELSE INSERT INTO tblHops_SatnoOpterecenje (DatumOpterecenja,Sat,Plan_MWh_Per_h, Ostvarenje_MWh_Per_h, tblHops_SatnoOpterecenje_ID) VALUES ('" & [DatumOpterecenja] & "','" & [Sat] & "'," & [Plan_MWh_Per_h] & "," & [Ostvarenje_MWh_Per_h] & ", '" & [tblHops_SatnoOpterecenje_ID] & "')#(lf)SELECT * FROM tblHops_SatnoOpterecenje"), #"Changed Type of SQL expression column" = Table.TransformColumnTypes(#"Added Custom4", {{"Create SQL expression", type text}}), AddSQLColumn = Text.Combine(#"Changed Type5"[AddSQLColumn]," "), Source3 = Sql.Database("server.xxxxxxx,12314", "NameOfDB"), INSERT = if Text.Length(AddSQLColumn)> 1 then Value.NativeQuery(Source3, AddSQLColumn) else Table.TransformColumnTypes(#table({"A"},{{0}}), {{"A", type text}}) in INSERT
@gabrielkn
@gabrielkn 4 жыл бұрын
Interesting .. would this be adaptable for a medium size table to be written back to SQL?
@BIElite
@BIElite 4 жыл бұрын
I'm not sure how this performance would look with scale. I imagine someone can come up with some better SQL to check if the record already exists, and then this should work ok.
@gabrielkn
@gabrielkn 4 жыл бұрын
@@BIElite I was thinking more on a flush and fill technique, definitely something to try. Thank you!
@novak2033
@novak2033 4 жыл бұрын
Amazing! Thanks a lot!
@BIElite
@BIElite 4 жыл бұрын
No problem Jasa!
@rakeshnag70
@rakeshnag70 4 жыл бұрын
Can we use this approach with sap data sources ?
@mehulbhatia5469
@mehulbhatia5469 3 жыл бұрын
Is it possible to writeback dax measure to sql server?
@shashankjyothi7979
@shashankjyothi7979 2 жыл бұрын
Hi. Does anyone know if you can write to a SQL db from a power BI report that has been published to a workspace?
@MTerkait
@MTerkait 4 жыл бұрын
Hello, and thanks for the video, but I'm looking to change a value in the table, give the user to privilege to click and modify the Value in the table, and updating it where it should reflect back to the SQL/Oracle Database.
@davidlang8101
@davidlang8101 4 жыл бұрын
I need this too, is there any way a user could do an entry, and to push this value back to the DB? Thanks.
@hoke73
@hoke73 3 жыл бұрын
Hi, this is great. is there a way to do the same against oracle database? I get error ORA-00933 while running several sql statements in one value.nativequery. thx in advance
@roxanarodriguez1828
@roxanarodriguez1828 4 жыл бұрын
Woa can be this done with sharepoint list? or excel?
@BIElite
@BIElite 4 жыл бұрын
Yes it can! Any data source will work.
@roxanarodriguez1828
@roxanarodriguez1828 4 жыл бұрын
@@BIElite Oh really? is it the same process? isn't it? thank you very much
@lohitmm
@lohitmm 3 жыл бұрын
can you share this Power Bi file please for reference?
@majdyazigi8185
@majdyazigi8185 4 жыл бұрын
Great video, just a question : does this work with MS Access database
@BIElite
@BIElite 4 жыл бұрын
Not totally sure, but you might be able to test it fairly quickly!
@jorgeeduardomoltenimoreno3048
@jorgeeduardomoltenimoreno3048 4 жыл бұрын
Nice Tip Man! thanks
@BIElite
@BIElite 4 жыл бұрын
No problem Jorge!
@aswin131
@aswin131 4 жыл бұрын
How to insert the values to sql database, if we have mutliple records to be inserted?
@BIElite
@BIElite 4 жыл бұрын
You would need to employ some logic to group the rows together instead of drilling down into the value like I do in the video.
@mikapeltokorpi7671
@mikapeltokorpi7671 4 жыл бұрын
Thanks for the video. BTW: That's true "How to lie with statistics" classic in the first pic (showing 1,3 M to ... 1,3 M views) 😂
@BIElite
@BIElite 4 жыл бұрын
Scale could have been better for sure!
@jcmv007
@jcmv007 4 жыл бұрын
Hi Parker, awesome video tried it out but got stuck on the Drill Down part as the values are not changing for new records, was only able to insert the one record. How can I get it to work?
@Rafian1924
@Rafian1924 3 жыл бұрын
Yes, Same case goes with me.
@yoismelperez2744
@yoismelperez2744 3 жыл бұрын
Yes, same here. James, were you able to find out how to get around this?
@yoismelperez2744
@yoismelperez2744 3 жыл бұрын
@@Rafian1924 same here, were you able to find out how to get around this?
@jcmv007
@jcmv007 3 жыл бұрын
@@yoismelperez2744 nope I was not.
@yoismelperez2744
@yoismelperez2744 3 жыл бұрын
@@jcmv007 I just did. Need to use Result = Text.Combine(AddSQLColumn, " ") right after creating the list
@MuhammadBerki
@MuhammadBerki 4 жыл бұрын
Fantastic tip, thank you 🙂
@BIElite
@BIElite 4 жыл бұрын
No problem, Muhammad!
@AdamSaxton
@AdamSaxton 4 жыл бұрын
Just want to call out to be very careful with doing any type of INSERT/UPDATE/etc... within Power Query. In the video he had a check to make sure to not insert if it already exists which is good. the statement can run one or more times - which could lead to problems. Be very very careful. 🙏
@BIElite
@BIElite 4 жыл бұрын
Hi Adam, thanks for the input. I tried to make this point clear in the video.
@ertf7777
@ertf7777 6 ай бұрын
Will the source sata will get affected if we write insert/update in power query?
@rakeshpanigrahi577
@rakeshpanigrahi577 4 жыл бұрын
Thanks Sir
@NikoSuomiUlkoilee
@NikoSuomiUlkoilee 4 жыл бұрын
Interesting!
@amarnadhgunakala2901
@amarnadhgunakala2901 4 жыл бұрын
missed SQL double check
@rubenbasco7554
@rubenbasco7554 Жыл бұрын
Like it, but looks so complicated...
@Crisicus_01
@Crisicus_01 3 жыл бұрын
This is awfully hacky for something you can do with a stored procedure and an SQL job.
@ПавелЛинев-ч7м
@ПавелЛинев-ч7м 3 жыл бұрын
норм 🙈
@sonhuynhtien4744
@sonhuynhtien4744 2 жыл бұрын
how did you do it can you share with me , thank you
BULK Write Back to SQL from Power BI
11:40
BI Elite
Рет қаралды 32 М.
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 2,3 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 72 МЛН
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 87 МЛН
Watermelon magic box! #shorts by Leisi Crazy
00:20
Leisi Crazy
Рет қаралды 78 МЛН
How I Use SQL as a BI Analyst
9:01
Adam Finer - Learn BI Online
Рет қаралды 27 М.
Native Query: Be careful when using in Power BI
8:49
Guy in a Cube
Рет қаралды 55 М.
Performance Tuning Power Query And Dataflows In Power BI
55:09
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 2,3 МЛН