Important: This post was written and published in 2018, and the content below no longer represents the current capabilities of Power BI. Please consider this post to be an historical record and not a technical resource. All content on this site is the personal output of the author and not an official resource from Microsoft.
A few recent posts have touched on different aspects of how dataflows have capabilities that aren’t exposed in the current preview user experience in Power Query Online. This is true of Power Query “M” functions, and of using custom functions, and it is also true of data sources.
Not every data source that is supported in Power BI Desktop is supported today in dataflows, but these data sources should work[1]:
- SAP Business Warehouse
- SAP HANA
- Azure Analysis Services
- Google Analytics
- Adobe Analytics
- ODBC
- OLE DB
- Folder
- SharePoint Online folder
- SharePoint folder
- Hadoop HDFS
- Azure HDInsight (HDFS)
- Hadoop file HDFS
- Informix (beta)
For any of these data sources, you should be able to build a query in Power BI Desktop, copy it and paste it into Power Query Online and have it work, even though the data sources are not yet listed in the UX.
Let’s look at an example using the Folder source, both because the Folder data source is not yet supported in the Power Query Online user experience, and because of how to relates to yesterday’s post on using custom functions[2]. We’ll begin by choosing a folder that contains our data files.
Once we’ve connected to the folder, we’ll edit the query to load the data from all CSV files that the folder contains, and then combine the contents of the files.
Once we’re done, Power Query in Power BI Desktop will give us this:
There are three points worth mentioning in this image:
- The data itself – this is probably what grabs your attention, because it’s big and data
- The set of queries built by Power BI Desktop includes multiple queries and a custom function
- The main query loaded into the PBIX data model references the other query and the custom function
Now let’s take it all from Power BI Desktop and use it in a dataflow. As covered in the post on authoring Power BI dataflows in Power BI Desktop, right-clicking on the query and choosing “Copy” will copy all of the script we need. Like this:
// Demo File Source
let
Source = Folder.Files("C:\Demo File Source"),
#"Filtered Rows" = Table.SelectRows(Source, each Text.EndsWith([Name], ".csv")),
#"Filtered Hidden Files1" = Table.SelectRows(#"Filtered Rows", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File from Demo File Source", each #"Transform File from Demo File Source"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File from Demo File Source"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File from Demo File Source", Table.ColumnNames(#"Transform File from Demo File Source"(#"Sample File"))),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Date received", type date}, {"Product", type text}, {"Sub-product", type text}, {"Issue", type text}, {"Sub-issue", type text}, {"Consumer complaint narrative", type text}, {"Company public response", type text}, {"Company", type text}, {"State", type text}, {"ZIP code", type text}, {"Tags", type text}, {"Consumer consent provided?", type text}, {"Submitted via", type text}, {"Date sent to company", type date}, {"Company response to consumer", type text}, {"Timely response?", type text}, {"Consumer disputed?", type text}, {"Complaint ID", Int64.Type}})
in
#"Changed Type"
// Transform File from Demo File Source
let
Source = (#"Sample File Parameter1") => let
Source = Csv.Document(#"Sample File Parameter1",[Delimiter=",", Columns=18, Encoding=1252, QuoteStyle=QuoteStyle.Csv]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in
#"Promoted Headers"
in
Source
// Sample File
let
Source = Folder.Files("C:\Demo File Source"),
#"Filtered Rows" = Table.SelectRows(Source, each Text.EndsWith([Name], ".csv")),
Navigation1 = #"Filtered Rows"{0}[Content]
in
Navigation1
Isn’t that sweet?
We can then paste each of these queries into the “Blank query” template in Power Query Online. Power Query Online is smart enough to automatically prompt for a gateway and credentials. The only edit we’ll need to make is to remove the one line that’s highlighted in red[3], and then… it just works.
There’s certainly a little irony involved in using the phrase “it just works” after going through all of these steps… but it does work.
While Power BI dataflows and Power Query Online are in preview, there are likely to be some rough edges. But because dataflows are built on the same Power Query function language and connectivity platform, which means that in many scenarios you can use dataflows for tasks that are not yet fully supported in the interface.
During preview there are still functions and data sources that aren’t yet supported in dataflows, but this technique can unlock data sources and capabilities that aren’t yet exposed through the UI. Check it out.
[1] As the rest of the blog makes clear, I have not yet tested all of these. If you try any of them and they don’t work, remember this: Getting Help for Power BI Dataflows.
[2] But mainly because I don’t have any of the other listed data sources handy to use.
[3] Because this is not yet supported in dataflows.
Pingback: Dataflows in Power BI – BI Polar
Thank you for this blog post. We tried to test this yesterday by recreating all of the queries in the normal “combine binaries” experience (sample file, function, etc) and it even though it failed, it seemed like the potential was there. So excited to try again now.
LikeLike
I wrote and tested this blog post earlier in the week, so if you tried this yesterday it should have worked.
LikeLike
It did work! I needed to disable load on the Fx and sample but it did begin refreshing. Thank you for helping us get moving on this. I have so many things to map and reroute now. There goes my week next week. 🙂
LikeLike
That’s awesome to hear – thank you!
LikeLike
Hi there, it didn`t work for me either for several days. I use Power Query in German language and here the fx is named as “Datei aus Abfrage1 transformieren” (=Invoke Custom Function1). I always got an error message until I found out that there are two additional spaces between “aus Abfrage1” and “Abfrage1 transformieren” in the function name. After I adjusted the fx-name accordingly with the additional blanks it ran. Maybe it can help you, too. @Matthew: Thank you so much for your instructions, they were fantastic.
LikeLike
Thanks for sharing the workaround!
LikeLike
There’s not really enough information here to work with – there’s just an error message out of context. If you’re asking for help, please provide a complete error repro, including the steps you’re taking to get the error.
LikeLike
I figured it out. I had a mistake in the Query. Thanks!
LikeLike
That’s awesome to hear – thanks for following up!
LikeLike