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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Anonymous
Not applicable

Get and append data in PBI the optimal way - flat files

Hello everyone!

 

I'm building a data model where I have to import data from several flat files. The sales data is provided to me in Excel and it is currently split into separate files for each quarter. I have them all saved in a folder. Each file is roughly 500k rows and 50 columns. Once I import each of these files, they go through some transformation steps where I: remove a couple of columns and unnecessary rows, change data types (partly text, partly fixed decimal), replace nulls with 0.


Ideally, I would like to automatically apply the steps from prior files to newly imported files. Currently I make the same changes for each file. Moreover, I would like to ensure the model loads only the new data once available.

Could you please advise how to create an efficient appending and cleaning process?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous  The below steps could be used to filter your data on the most recent:

- Create a conditional column for Month:

bchager6_0-1705335586903.png

 

- Ensure that Fiscal Year, Quarter, and Month are text data types

 

- Add a Date Custom Column using this code:
= [Month] & "/" & "1" & "/" & [Fiscal Year]


- Change the Date column's data type to Date

 

- Apply the "Is Latest" Date Filter to your Date column

 

bchager6_1-1705335859429.png

 

 

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

@Anonymous  You're welcome. Here's a good read on the approach: https://learn.microsoft.com/en-us/power-query/connectors/folder

Anonymous
Not applicable

@Anonymous  I would look into using either a Folder connector or SharePoint Folder connector, and the Is Latest filter on a the date column aligned to the updated date of the file.

If you're not aware, using a Folder connector will enable the import and append of new data each time it's added to your folder and the Power BI report is refreshed. The Is Latest filter will ensure that only the most recent data is loaded.

Let me know if you have any questions.

Anonymous
Not applicable

I've followed the instructions and I'm able to connect to the folder and apply transformation steps to all the files. However, when I save a new file and refresh the model, I noticed that all the other files get loaded again; as seen in this snapshot, where Q2 is only the second out of the 13 files I need to include in the model. How do I load and transform only the newly saved data?

CCART92_0-1705331286388.png

 

Anonymous
Not applicable

@Anonymous  Is there an Updated Date for each file that you can apply an Is Latest filter in the Query Editor to?

Anonymous
Not applicable

Each file has a column for Fiscal Year and one for quarter. Could those be used as identifiers?

Anonymous
Not applicable

@Anonymous  The below steps could be used to filter your data on the most recent:

- Create a conditional column for Month:

bchager6_0-1705335586903.png

 

- Ensure that Fiscal Year, Quarter, and Month are text data types

 

- Add a Date Custom Column using this code:
= [Month] & "/" & "1" & "/" & [Fiscal Year]


- Change the Date column's data type to Date

 

- Apply the "Is Latest" Date Filter to your Date column

 

bchager6_1-1705335859429.png

 

 

Anonymous
Not applicable

Thank you! I will try to replicate what you suggested, but I'm afraid it will be a bit trickier as I don't have a month dimension. Still, the query should recognize that the cronology is Q1,Q2,Q3,Q4. I will take time to work on this in the following days and hopefully reach/mark a solution.

Anonymous
Not applicable

@Anonymous  You're welcome. It's OK that you don't have a month dimension. The process I described creates a month column, using the first month of each quarter. It assumes a fiscal year-end of December though, so you'd need to tweak the code if your fiscal year-end is different.

Anonymous
Not applicable

Yes. Using the fiscal year and quarter columns in the query editor, you could produce an "updated date" column and apply the Is Latest filter to it.

 

I can show you an example in a few hours. In the meantime, I recommend  looking into the Text.Combine M function and in general how to combine columns in the Query Editor.

Anonymous
Not applicable

Thanks, will look into it and update the post if it works.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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