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.
Hi
I would like to create below switch statement using column. I have tried, but it's not showing the values. If it's possible please let me know
SWITCH(
TRUE(),
SELECTEDVALUE(Columns_names[Query1])="A",FIRSTNONBLANK(Orders[A],1),
SELECTEDVALUE(Columns_names[Query1])="B",FIRSTNONBLANK(Orders[B],1),
SELECTEDVALUE(Columns_names[Query1])="C",FIRSTNONBLANK(Orders[C],1),
"Nothing")
Thanks in advance
I have a suspicion that you are likely not using SELECTEDVALUE correctly but that is really hard to say without context. If you are trying to do this in a calculated column for example, I would not use SELECTEDVALUE in that case, I would just use the column name. Also, using SWITCH TRUE here technically does not make sense, just use the standard form of SWITCH. So you might try:
Column =
SWITCH(
[Query1],
"A",FIRSTNONBLANK(Orders[A],1),
"B",FIRSTNONBLANK(Orders[A],1),
"C",FIRSTNONBLANK(Orders[A],1),
"Nothing"
)
If this is a measure, I would try this:
Measure =
SWITCH(
MAX('Columns_names'[Query1]),
"A",FIRSTNONBLANK(Orders[A],1),
"B",FIRSTNONBLANK(Orders[A],1),
"C",FIRSTNONBLANK(Orders[A],1),
"Nothing"
)
From the below Actual output if we select any value from Input_Groups, it's reflecting the same in the table visual, let's say if i select All, it will appeare in the table , same other values also.
But my requirement is if i dont select any values from Input_Groups it has to come like below output with aggerated values else by default it has to display "ALL". With All we can see aggregated values.
Usevally what i was doing, by default selecting the "All" values and deploying into the services. But if user remove the filter from the Input_Groups it will give all detailes values and aggreageted values will split .
Sample File: https://drive.google.com/file/d/1I4iiRDKf-H9vQ0vU4BTtGpn-Ey0YeiT/view?usp=sharing
If it's possible please let me know.
Thanks in advance
After looking at your PBIX it strikes me that you might possibly want to unpivot your three columns to obtain a single column and then things will be easier. I would try this, but I do not have your Sample.xlsx file so I cannot test this out. But, I'm pretty sure that unpivoting would pretty much make this a cake walk.
I have attached xlsx file. could u pleaase check and lt me know the solutions.
Sample PBIX : https://drive.google.com/file/d/1I4iiRDKf-H9vQ0vU4BTtGp-Ey0YehiT/view?usp=sharing
Sample.xlsx file : https://drive.google.com/file/d/1brZTsnfqx0mTryREYkTrb5PreaC5mO8a/view?usp=sharing
Regards,
Hari
When you this calculation in measure context is very important. Can you share sample data and sample output.
In between try
var _max = maxx(Columns_names,SELECTEDVALUE(Columns_names[Query1]))
SWITCH(
TRUE(),
_max="A",FIRSTNONBLANK(Orders[A],1),
_max="B",FIRSTNONBLANK(Orders[B],1),
_max="C",FIRSTNONBLANK(Orders[C],1),
"Nothing")
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 | |
68 | |
53 | |
39 | |
33 |
User | Count |
---|---|
70 | |
63 | |
57 | |
49 | |
46 |