Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Replace custom SQL datasource with dataflow

l have apublished report that uses a custom SQL as its datasource.  I created a dataflow using the M-code version of that SQL.  It is published, refreshes, etc with no issues.

 

Now I want to take a few existing reports that use this SQL as the main datasource, and convert them to use the dataflow I have created.  I have searched these forums and elsewhere but am unable to find a solution to this particular question.

 

I was able to make a new datasource in the report using the dataflow.  But this report has many VIZ (30+) and I don't want to recreate them all using the new dataflow datasource.

 

Is there a way to either (1) modify the SQL datasource by replacing the custom SQL with the new dataflow, or tell Power BI to use the dataflow instead of the SQL datasource (I would then delete the SQL from the datasource list)?

 

Thanks in advance for any help this community can provide

3 REPLIES 3
Anonymous
Not applicable

 I identified the solution to this issue.

 

To recap: you have multiple published workbooks.  Each uses the same custom SQL-based datasource.  Each has multiple tabs, with mulitple visuals on each tab.  Since they use the same datasource, it would be more efficient to publish the datasource as a dataflow and then use that in each of the workbooks as the datasource.  The refresh procedure then only has to interact with your database once to refresh the data.  And if this is a standardized dataset, you only have to make an update in one place (the dataflow) if the logic changes, instead of having to update multiple workbooks and republish them.

 

The question is how to replace the existing visuals' reference to the SQL-based datasource, with a reference to the new dataflow.  Without having to rebuild each visual from new with a reference to the dataflow.  In my case it was over 100 visuals between 3 workbooks, which would be very time-consuming.

 

The answer:

1. Publish the datasource as a dataflow.

2. Open the workbook on your desktop and bring the dataflow in as a new datasource into your workbook.

3. Open "Advanced Editor" for the dataflow-based datasource to see the M-code. 

4. Copy the M-code to notepad+ or whatever you use.

5. Open "Advanced Editor" for your original SQL-based datasource.

6. Paste the M-code from the dataflow into the Advanced Editor.  (if you look, you'll see the M-code is now different). 

7. Close the advanced editor window and let the workblook update its data.

 

Your workbook is now leveraging the published dataflows, and you did not have to rebuild the visuals or make any changes to it.  You should be able to close out the "new" dataflow datasources you brought into the workbook, leaving only the original datasources (but these now leverage the published dataflow).

 

While each workbook will still have its own dataset in Power BI Server, and you still need to refresh them, they are connecting to the dataflow when they refresh.  And you will have to set up an automated refresh of the dataflow as well (if that is needed).  But this solution will only leverage the database once, instead of multiple times.  

 

One item to note:  some of my visuals used an advanced filter of where a field was "not blank".  The new dataflow was generating different results for those visuals.  I opened the filters in question, changed from advanced to basic filter, and then unchecked the "blank" or "null" option.  That gave me the correct result(s).

 

Hope the above helps others in this community.  This forum has been very helpful to me, and I am happy to give back.

 

 

Greg_Deckler
Super User
Super User

@Anonymous - Not certain but is this what you are looking for?

https://exceleratorbi.com.au/moving-queries-from-power-bi-desktop-to-dataflows/

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Appreciate the feedback, but that link is giving you instruction on how to set up a dataflow.  I've already done that.   And I've brought it into my PBIX as a new datasource.

 

Now I have 30+ visuals, that are currently using the SQL-based datasource.  I want them to reference the new dataflow instead.  But I can't seem to find any tips on how to do that.  

 

Ultimately I have a number of workbooks using this SQL.  They all have their own datasource that needs to be refreshed.  I'm trying to replace all of those individual datasources, with one standardized dataflow.  

 

In order to do this, I need to tell the PBIX to use the dataflow instead of the SQL.  I can then delete the individual datasources and will only have to refresh the single dataflow each day.  

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.