Okay, let's break down how to achieve these three goals in Power BI.
1. Reading the Latest File from a Folder
This is a classic Power Query task. You'll connect to the folder instead of a specific file.
-
Steps in Power BI Desktop:
- Go to
Home > Get Data > More....
- Search for and select
Folder. Click Connect.
- Browse to or enter the path to the folder where your data files will be stored. Click
OK.
- A preview window will show the files in the folder. Click
Transform Data. This opens the Power Query Editor.
- You'll see a table listing the files and their metadata (Name, Extension, Date accessed, Date modified, Date created, Folder Path, Attributes, Content).
- Crucial Step: Filter to the Latest File:
- Find the
Date modified column (or Date created if that's more appropriate for your process).
- Click the filter/sort arrow on that column header.
- Choose
Sort Descending. This puts the most recently modified file at the top.
- Go to the
Home tab in the Power Query Editor ribbon.
- Click
Keep Rows > Keep Top Rows.
- Enter
1 in the dialog box and click OK. Now you only have the row corresponding to the latest file.
- Combine/Extract Data from the Latest File:
- Look at the
Content column. It should say Binary.
- If you only need data from this one latest file, click the
Combine Files button (double downward arrows icon) in the header of the Content column. Power BI will guide you through selecting the sheet/object within the file (e.g., an Excel sheet) and automatically create helper queries to handle the extraction.
- Alternatively (more manual control): You can remove all columns except the
Content column (Right-click Content header > Remove Other Columns). Then, click on the Binary link within the Content cell. Power BI will attempt to interpret the file. If it's Excel, you'll see Sheets/Tables. Click on the specific Table or Sheet you need. Power Query will add steps to navigate to and expand the data.
- Clean and Transform: Perform any other necessary transformations (promote headers, change data types, etc.) just like you would if you connected to a single file.
- Click
Close & Apply on the Home tab.
-
Result: Every time you refresh your Power BI report, Power Query will re-evaluate the folder contents, sort by date, pick the latest file, and load its data.
2. Adding Searchable Tags (Keywords)
This is exactly what we discussed previously.
- In Your Excel File: Ensure you have a column (let's assume it's still Column C, but adjust as needed) containing your comma-separated keywords (e.g.,
gloves,fingers,hand, shirt,cotton,blue, etc.).
- In Power BI:
- Make sure this column is loaded into your Power BI data model (it should be after step 1). Ensure its data type is
Text.
- Best Method: Search Box with DAX Measure:
- Go to
Modeling > New Parameter > Text.
- Name it something like
Keyword Search Parameter. Leave the default value blank. Check Add slicer to this page. This creates a table for the parameter and a slicer on your report page.
- Create a new DAX Measure:
Keyword Filter =
VAR SearchTerm = LOWER( TRIM( 'Keyword Search Parameter'[Keyword Search Parameter] ) ) // Get input, lowercase, remove whitespace
VAR CurrentKeywords = LOWER( SELECTEDVALUE( 'YourDataTable'[YourKeywordColumn] ) ) // Get keywords for the current row, lowercase
RETURN
IF (
ISBLANK( SearchTerm ), // If search box is empty...
1, // ...show everything
IF (
CONTAINSSTRING( CurrentKeywords, SearchTerm ), // Check if keywords contain the search term
1, // Show row if match found
0 // Hide row if no match
)
)
- Replace:
'Keyword Search Parameter'[Keyword Search Parameter] with the actual name generated for your parameter.
'YourDataTable' with the name of your main data table (the one loaded from the latest Excel file).
'YourDataTable'[YourKeywordColumn] with the name of the column containing your comma-separated keywords.
- Select the visual you want to filter (e.g., a Table, Matrix, Gallery).
- Drag the
Keyword Filter measure onto the "Filters on this visual" pane in the Filters sidebar.
- Set the filter condition to
is 1. Click Apply filter.
- Now, users can type into the slicer generated by the parameter, and the visual will filter based on whether the typed text appears within the comma-separated keywords for each product.
3. Linking and Displaying Local Images
This is the trickiest part due to Power BI's design, especially for sharing.
-
The Challenge: Power BI (especially the Service, where you publish reports) cannot directly access local file paths (like C:\Users\YourName\Pictures\product1.jpg) for security reasons. It works inconsistently, if at all, only in Power BI Desktop on the machine where the files exist. Reports won't work for other users or online.
-
Viable Solutions:
-
Option A: Web URLs (Recommended for Sharing):
- Store Images Online: Upload your images to a web-accessible location like:
- A public website / web server
- SharePoint Online Document Library
- OneDrive for Business
- Azure Blob Storage (with public access or SAS tokens)
- Add URL Column: In your Excel data, add a column that contains the full web URL for each product's image.
- Load Data: Load this data into Power BI (as part of Step 1).
- Set Data Category: In Power BI's Data view or Model view, select the column containing the image URLs. In the
Column tools ribbon, change the Data category to Image URL.
- Display: Add this Image URL column to a Table, Matrix, Card, or dedicated image visuals (like the standard Image visual or custom visuals). Power BI will render the image from the web.
-
Option B: Base64 Encoding (Works Offline/Shared, Increases File Size):
- Convert Images: Convert each image file into a Base64 text string. This can be done using online converters, programming scripts (Python, PowerShell), or potentially some Power Query custom functions (though this can be complex and slow).
- Add Base64 Column: In your Excel data, add a column to store the entire Base64 text string for each image. These strings are very long.
- Load Data: Load this data into Power BI.
- Create URL String: Create a new calculated column in Power BI using DAX:
Image Base64 URL = "data:image/png;base64," & 'YourDataTable'[YourBase64Column]
- Replace
image/png with the correct image type (jpeg, gif, etc.) if needed.
- Replace
'YourDataTable'[YourBase64Column] with the column containing the raw Base64 strings.
Summary Recommendation:
- Use Power Query to connect to the Folder and filter/sort to get the latest file.
- Implement the Searchable Tags using a Text Parameter and a DAX Measure with
CONTAINSSTRING.
- For Images, strongly prefer Option A (Web URLs) for reliability and sharing. If offline access is absolutely critical and you accept the file size increase, use Option B (Base64 Encoding). Avoid relying on direct local file paths.