Forum Discussion
URL Filter - Seeking help on IN filter
- 2 years ago
This page covers all of the URL filter encoding rules:
https://learn.microsoft.com/en-us/power-bi/collaborate-share/service-url-filters
Particular rules that are relevant for your situation:
- Spaces in table or column names must be encoded as _x0020_
This is why the Project Type filter wasn't working. - Spaces and other special characters in values must be encoded generally using %-code, e.g. space is %20.
(already appears correct in your example).
For your particular filter, this should be the correct filter portion of the URL:
filter=AutomationLibrary/Project_x0020_Type%20in%20(%27All%20Project%20Types%27,%27Corporate%20Restructure%27)I tested this with a dummy report myself and it worked as intended.
Does this work for you?
- Spaces in table or column names must be encoded as _x0020_
- 2 years ago
Hi taylorpeter55, no worries, good to hear from you!
I had a look through the URL filter documentation and there don't appear to be any substring-based filtering options. The 'in' filter just checks for an exact match with any of the items between the brackets.
While Power BI URL filters are based on OData filters, Power BI has a more limited set of options unfortunately.
I would instead recommend adjusting the semantic model so that you can use an 'in' filter on another specially constructed table. I have attached a PBIX as an example.
Here are the steps I would suggest:
1. Create a new table, which I called 'Project Type Concatenated'. This contains the distinct values from AutomationLibrary[Project Type] (each of which is a comma-delimited list):
2. Create another new table, which I called 'Project Type Individual'. This contains all combinations of the original Project Type Concatenated values and the individual Project Type values. I created it using the Splitting function in Power Query:
3. Create relationships as follows
(note the bidirectional relationship between 'Project Type Concatenated' and 'Project Type Individual') :4. Now, you can apply a filter on 'Project Type Individual'[Project Type], and this will have the effect of selecting any of the original Project Type column containing any of the selected individual Project Types:
5. For the URL filter, apply the 'in' filter to 'Project Type Individual'[Project Type]:
filter=Project_x0020_Type_x0020_Individual/Project_x0020_Type%20in%20(%27All%20Project%20Types%27,%27Corporate%20Restructure%27)Does something like this work for you?
Regards
Hi taylorpeter55, no worries, good to hear from you!
I had a look through the URL filter documentation and there don't appear to be any substring-based filtering options. The 'in' filter just checks for an exact match with any of the items between the brackets.
While Power BI URL filters are based on OData filters, Power BI has a more limited set of options unfortunately.
I would instead recommend adjusting the semantic model so that you can use an 'in' filter on another specially constructed table. I have attached a PBIX as an example.
Here are the steps I would suggest:
1. Create a new table, which I called 'Project Type Concatenated'. This contains the distinct values from AutomationLibrary[Project Type] (each of which is a comma-delimited list):
2. Create another new table, which I called 'Project Type Individual'. This contains all combinations of the original Project Type Concatenated values and the individual Project Type values. I created it using the Splitting function in Power Query:
3. Create relationships as follows
(note the bidirectional relationship between 'Project Type Concatenated' and 'Project Type Individual') :
4. Now, you can apply a filter on 'Project Type Individual'[Project Type], and this will have the effect of selecting any of the original Project Type column containing any of the selected individual Project Types:
5. For the URL filter, apply the 'in' filter to 'Project Type Individual'[Project Type]:
filter=Project_x0020_Type_x0020_Individual/Project_x0020_Type%20in%20(%27All%20Project%20Types%27,%27Corporate%20Restructure%27)
Does something like this work for you?
Regards
OwenAuger Thank you so much! This solution is brilliant 🙂
I've replicated it in my full dashboard and the dashboard and URL filter are now working perfectly 🙂
I honestly can't thank you enough - I will certainly remember this solution and will definitely be reusing it in future.
Pete