We created a looker studio dashboard and we need to enhance our search function.
1. How can we design the search function to handle variations in the part number format, including upper/lowercase and special characters like "-"?
2. Is it possible to create a solution that can handle different SKU/part numbers syntax?
3. What approach should be taken to ensure that incomplete part numbers can still be effectively searched for?
So, here are examples of what we need:
P1111208 needs to found by P111-1208 or p111-1208 or P1111208
F44485D1 needs to be found by F44485D1 or F44485D1 f44485d1
T117788-01 needs to be found by t117788-01 or t11778801 or T11778801
I think this would solve the Upper / Lowercase, but not sure about the "-" dash character
https://support.google.com/looker-studio/thread/79360093/i-want-to-remove-the-match-type-characters-...
Any guidance will be appreciated.
Solved! Go to Solution.
Here is the way I ended up solving the issue.
1. Converting everything to lower case, using LOWER and eliminating "-", it seems like REPLACE used as below is working as expected
LOWER(REPLACE(PartNumber, "-", ""))
I did that for the Part Number and the Search Text
1. Handle Variations in Part Number Format
To ensure the search function can handle variations in part number format (including uppercase, lowercase, and special characters like dashes), you can use a combination of data transformations and search logic.
Normalize Data:
Create Calculated Fields:
In your search input processing, ensure the input is normalized similarly by converting it to lowercase and removing special characters.
By normalizing the part numbers and the search input, you can ensure that variations in syntax are handled effectively.
To handle incomplete part numbers, you can use a CONTAINS or LIKE clause in your search logic.
Assuming you have a normalized part number field (NormalizedPartNumber) and a normalized search input (normalized_search_input), your query might look like this:
This query will allow you to search for part numbers even if the input is incomplete.
Create a Parameter for Search Input:
Create a Filter:
Create a Calculated Field for Normalized Part Number:
Create a Parameter for Search Input:
Create a Calculated Field for Normalized Search Input:
Create a Filter:
I'd recommend using LOWER (or UPPER) in your search to make sure all capitalization is consistent.
As for regexp replace, yeah you're on the right track! You can modify that example to include a dash like so:REGEXP_REPLACE(Field, "([\\+\-\\[\\]])", "")
Thanks Sam8!
Here is the way I ended up solving the issue.
1. Converting everything to lower case, using LOWER and eliminating "-", it seems like REPLACE used as below is working as expected
LOWER(REPLACE(PartNumber, "-", ""))
I did that for the Part Number and the Search Text
1. Handle Variations in Part Number Format
To ensure the search function can handle variations in part number format (including uppercase, lowercase, and special characters like dashes), you can use a combination of data transformations and search logic.
Normalize Data:
Create Calculated Fields:
In your search input processing, ensure the input is normalized similarly by converting it to lowercase and removing special characters.
By normalizing the part numbers and the search input, you can ensure that variations in syntax are handled effectively.
To handle incomplete part numbers, you can use a CONTAINS or LIKE clause in your search logic.
Assuming you have a normalized part number field (NormalizedPartNumber) and a normalized search input (normalized_search_input), your query might look like this:
This query will allow you to search for part numbers even if the input is incomplete.
Create a Parameter for Search Input:
Create a Filter:
Create a Calculated Field for Normalized Part Number:
Create a Parameter for Search Input:
Create a Calculated Field for Normalized Search Input:
Create a Filter:
User | Count |
---|---|
4 | |
2 | |
2 | |
1 | |
1 |