I am wanting to create a filter where the text dynamically changes based on what the options that are selected.
At the moment I have two groups which are called ‘Food’ and ‘Sub-Food’. I have three ‘Foods’ and each ‘Food’ has several ‘Sub-Foods’ underneath it. Please see below (or refer to attached PBIX file):
Fruit (Apple, Orange, Mango)
Vegetable (Carrot, Lettuce, Broccoli)
Meat (Beef, Pork, Chicken)
I would like to create a formula that displays the text based on the values selected (it concatenates) but if all values are selected in that particular food group, it will display the high level, e.g. Meat will be displayed if all the values in its ‘Sub-Foods’ have been selected, in this case, beef, pork & chicken
Desired Outputs
If apple and mango are selected it will display: Apple, Mango
If apple, mango and orange are selected (as all the values in the ‘Fruit’ group are selected), it will display: Fruit
If apple, mango, orange and chicken are selected, it will display: ‘Fruit, Chicken’
If apple, orange, mango, beef, chicken and pork are selected (these are all the values in the subgroup), it will display: Fruit, Meat
I’ve attached a PBIX file with the values. Thanks in advance.
To create a formula that dynamically displays the text based on the selected options in your “Food” and “Sub-Food” columns, you can use a combination of IF and SWITCH statements. Here’s an example of how you can do this:
This formula works by first checking if the number of selected items in the “Food” column is equal to the number of selected items in the “Sub-Food” column. If that’s the case, it means that all the items in the “Sub-Food” column have been selected, so the formula uses the SWITCH statement to return the corresponding high-level category (“Fruit”, “Vegetable”, or “Meat”). If not, it uses the CONCATENATEX function to concatenate the selected items in the “Food” column, separated by a comma and a space.
I hope this helps! Let me know if you have any questions.
Your explanation makes sense but unfortunately I am still encountering some errors.
When I select, Broccoli, Carrot and Lettuce (as all values have been selected), the text ‘Vegetable’ should appear but it doesn’t.
Hello @leontan.3
Due to the length by which this post has been active, we are tagging it as Solved.
Thanks to the contributors of this post.
For further questions related to this post, please make a new thread. Please feel free to reopen this thread if anyone would like to answer the pending inquiry above.