Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi Guys,
Is the following possible to implement in Power Query?
I am sourcing set of CSV files from a folder in Azure Blob Storage. Then I am combining these files in Power query before loading the results to the model.
These two scenarios can occur:
1)This source folder may not have any CSV data files sometimes. In this case I dont want refresh to fail.
2)It is also possible that source folder is not present sometimes. In this case also I dont want refresh to fail.
Note: Structure of the file is fixed though.
How can I run the refresh of report sucessufully. Can somebody help me with the M query code for this.
Thanks
Solved! Go to Solution.
Hi @Mann
Then you add a last step to your queries that checks for existing errors and in case of error, produces an empty table. Usually it is necessary to have the column names still in place. You can hardcode such a table like so:
#table( {"ColName1, ColName2..."}, { { } } )
The step would look like so:
try <PreviousStepName> otherwise #table( {"ColName1, ColName2..."}, { { } } )
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
@Anonymous
Thanks for your thoughts on this.
Is it possible to do this technically in M query as I can't use Dataflows in current architecture.
If it is possible in M query can somebody give me some sample code to start with?
Mann.
<Looping some of Power Query experts who helped me learn through their impressive solutions in this community>
Hi @Mann
As I said the sample will vary depens on where you run your code. Is this Excel or Power BI Desktop?
Thanks,
JB
Hi @Mann ,
what should actually happen for the 2 occurrances you mentioned: Do you want to keep the old data or do you want to create an empty table?
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @Mann
Then you add a last step to your queries that checks for existing errors and in case of error, produces an empty table. Usually it is necessary to have the column names still in place. You can hardcode such a table like so:
#table( {"ColName1, ColName2..."}, { { } } )
The step would look like so:
try <PreviousStepName> otherwise #table( {"ColName1, ColName2..."}, { { } } )
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @ImkeF
Do you know a solution to another scenario - return old data (vs. return an empty table) in Power BI? I can solve it in PBI Dataflows and Excel PQ, but can't figure out for PBI Desktop.
Thanks,
JB
Hi @Anonymous
easiest would be to let it run into error, so the old data would be kept.
But if you're interested in incremental load, this article leads you to a couple of hacks/workarounds for Power BI: https://www.thebiccountant.com/2017/01/11/incremental-load-in-powerbi-using-dax-union/
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
@Anonymous
I want this code to run in Power BI Dekstop.
Mann.