Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I've been working on making a grouped slicer for a dashboard I'm creating, and I wanted to be able to make groups of countries for the slicer. I followed the guidance in the below post:
I used the following code to try to do this:
Group Selection =
SWITCH (
TRUE(),
'Compiled Data'[Country] IN {"USA", "UK", "Germany", "Austria", "Switzerland", "China", "Australia", "Canada"}, "P6",
'Compiled Data'[Country] IN {"Spain", "Italy", "France", "Taiwan", "Thailand", "Norway", "Denmark", "India", "Sweden"}, "E10",
'Compiled Data'[Country] IN {"Argentina", "Australia", "Brazil", "Canada", "China", "France", "Germany", "India", "Indonesia", "Italy", "Japan", "Mexico", "South Korea", "Saudi Arabia", "South Africa", "Turkey", "UK", "USA"}, "G20"
)
However, this returned the below error message:
A single value for column 'Country' in table 'Compiled Data' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.
I thought it may have been due to the overlapping countries between the final group and the other two, so I tried the same but without the final group and the same error message came up. Any suggestions on how I could fix this?
Many thanks!
Solved! Go to Solution.
Hi , @mm808
According to your description, when you use the SWITCH() function, it returns teh error code.
For this , i think you put this code in a measure . Right?
For this code , it should be in the calculated column in your table.Because the 'Compiled Data'[Country] can not be used in the measure.
In the measure , you need to use the Aggregate functions to get the value, like MAX() , MIN() or SELECTEDVALUE() .
You can try to use:
Group Selection =
SWITCH (
TRUE(),
MAX('Compiled Data'[Country]) IN {"USA", "UK", "Germany", "Austria", "Switzerland", "China", "Australia", "Canada"}, "P6",
MAX('Compiled Data'[Country]) IN {"Spain", "Italy", "France", "Taiwan", "Thailand", "Norway", "Denmark", "India", "Sweden"}, "E10",
MAX('Compiled Data'[Country]) IN {"Argentina", "Australia", "Brazil", "Canada", "China", "France", "Germany", "India", "Indonesia", "Italy", "Japan", "Mexico", "South Korea", "Saudi Arabia", "South Africa", "Turkey", "UK", "USA"}, "G20"
)
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , @mm808
According to your description, when you use the SWITCH() function, it returns teh error code.
For this , i think you put this code in a measure . Right?
For this code , it should be in the calculated column in your table.Because the 'Compiled Data'[Country] can not be used in the measure.
In the measure , you need to use the Aggregate functions to get the value, like MAX() , MIN() or SELECTEDVALUE() .
You can try to use:
Group Selection =
SWITCH (
TRUE(),
MAX('Compiled Data'[Country]) IN {"USA", "UK", "Germany", "Austria", "Switzerland", "China", "Australia", "Canada"}, "P6",
MAX('Compiled Data'[Country]) IN {"Spain", "Italy", "France", "Taiwan", "Thailand", "Norway", "Denmark", "India", "Sweden"}, "E10",
MAX('Compiled Data'[Country]) IN {"Argentina", "Australia", "Brazil", "Canada", "China", "France", "Germany", "India", "Indonesia", "Italy", "Japan", "Mexico", "South Korea", "Saudi Arabia", "South Africa", "Turkey", "UK", "USA"}, "G20"
)
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thanks very much, setting it as a table worked far better. However, there are some categories that overlap and the table only sees one of these values. Is there a way to fix this so that I can use this properly in a slicer?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
75 | |
63 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |