Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello, I am trying to create a measure or function that would display different results based on the number of things selected within a filter. I have tried using both IF statements and Switch Statements but I'm not getting them to work correctly. My current Switch Statement is sampleofhasonefilter = SWITCH(TRUE(),
DISTINCTCOUNT(inddir[Code+Name])>2,"n/A",
DISTINCTCOUNT(inddir[Code+Name])=1,SUM(iomatrix[Base Year Employment]),
DISTINCTCOUNT(inddir[Code+Name])=0,
CALCULATE(VALUES(iomatrix[Base Year Employment]),inddir[Industry Title]="Total All Industries"))
my inddir is what i want to filter by, and the the iomatrix is what I want my results to be, so if they select more than 1 filter (by using the control left click command, and yes single selection is turned on, control left click gets around this) I want them to get "N/A" in the card. If they select only one filter than they will get the result, of iomatrix, and if they do not select any/0, I want the card to return a default value which I have represented by my Calculate function. What is Currently happening is that it will read the first two lines and return "N/A" and even follow the 1 selection result but returns a blanks for the default. I have tested the calculate function in other cards seperate from the previous function and it seems to work as intended in those.
Thank you all again,
Regards,
MicrosoftRookie
Hi @microsoftrookie,
Based on my understanding, your default result part " CALCULATE(VALUES(iomatrix[Base Year Employment]),inddir[Industry Title]="Total All Industries") " returns a one-column table that contains the distinct values. However, a measure added to card visual can only display a single value. In your scenario, I would suggest you modify above expression to return a single value rather than a table, and try again.
Regards,
Yuliana Gu
Thank you for your timely response Mrs. Gu,
I apologize for my late response, however after trying to set it from values to bring down a specific value is not what seems to be the problem, because when i switched it to a table it shouldhave functioned like anticipated, however it did not. For example I made a dynamic title card with the following switch function which should return a specific value based on what is selected:
SWITCH(TRUE(),
DISTINCTCOUNT(Sheet1[Location])>=2,"Please select only one geography please",
DISTINCTCOUNT(Sheet1[Location])=1,"Displaying Numeric and Percent Change Results for "&VALUES(Sheet1[Location])&" by Industry Sector(except Total all Industries)",
DISTINCTCOUNT(Sheet1[Location])=0,"Displaying Numeric and Percent Change Results for New Jersey by Industry Sector(except Total all Industries)")
Currently the card will display the >=2 option as the default option even though the Distinctcount location column has nothing selected, but will function as intended if one thing is selected and will dynamically change to whatever was slected (i.e. If i hit New Jersey, it will fill in New Jersey and the same for New York).
This is strang because the >=2 option is functioning as a <>(does not equal)1 instead of actually accepting the math argument of selections being greater than 2, while completly ignoring the =0 option.
Thank you for your time,
Regards,
Microsoft Rookie.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
81 | |
67 | |
62 | |
46 | |
45 |