Regarding Step 2, I don't have the keywords column created, it must be created from, I'm assuming Power Query/DAX, from within Power BI. However, the data is such that the same product appear in multiple rows (different batch numbers) so I must somehow find all unique values, then write a suitable set of keywords and then apply it to every row where product matches the given keywords
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Ah, I understand now. Here's how to handle this scenario:
First, create a reference table of unique products with their keywords:
In Power Query, create a new query from your main data table
Remove duplicates based on the product column
Add a custom column for keywords
Here's the step-by-step approach:
code
1. In Power BI Desktop:
* Go to Transform Data to open Power Query Editor
* Right-click your main table in the Queries pane
* Select "Reference" to create a new query based on your main table
2. In the new query:
* Remove all columns except the product column
* Remove duplicates (Home > Remove Rows > Remove Duplicates)
* Add a custom column (Add Column > Custom Column)
* Name it something like "Keywords"
* Leave it empty or with default values initially
* Rename this query to something like "ProductKeywords"
3. Close Power Query Editor (Close & Apply)
4. In Power BI Desktop:
* Go to Enter Data (Home > Enter Data)
* Create a new table with your product-keyword mappings
* Columns should be: Product, Keywords
* Fill in your keywords for each product
* Name this table "ProductKeywordsMapping"
5. Create a relationship:
* Go to Model view
* Create a relationship between your main table's product column
* and ProductKeywordsMapping's product column
6. Create a calculated column in your main table:
* Go to Table Tools > New Column
* Write DAX like this:
```dax
Keywords =
LOOKUPVALUE(
'ProductKeywordsMapping'[Keywords],
'ProductKeywordsMapping'[Product],
'MainTable'[Product]
)
Now you can use this Keywords column for searching as discussed before.
This approach allows you to:
Maintain keywords centrally
Apply them consistently across all instances of the same product
Easily update keywords when needed
Keep the original data structure intact
Would you like me to elaborate on any of these steps?