The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi!
I've searched far and wide to find an answer and it feels like I've tried every possible combination I can think of, but have come up short so this is my last refuge.
I have a table with 3 columns. The first is text, the second is integer and the third is a switch measure intended to produce a value for each of the rows based on the first column or the second depending on switching with text or integer.
If I switch based on text in col 1 and the result is text I get the usual "can't compare text with true/false.
If I switch based on integer in col 2 and the result is integer I get the usual "can't compare integer with true/false.
If I switch with "if rank = 12, then 1 (all simple integers) I get an error and so on and so on...
The image below is just one of 100 combinations I've tried so you can see what I'm working with.
What is the correct way of solving this?
Solved! Go to Solution.
@KrisD , There two way you use switch
Switch( selectedvalues([column]) ,
"11", "Abc",
"12", "DEF"
)
Switch( true() ,
selectedvalues([column]) = "11", "Abc",
selectedvalues([column]) = "12", "DEF"
)
refer my video
Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56
@KrisD
Since you have conditions inside SWITCH, modify your formula as follows.
Replace SELECTEDVALUE ( 'Sammanstalling (2)' [Rank] ) with TRUE()
SWITCH ( TRUE() ,
'Sammanstalling (2)' [Rank] = 12 , [Gra..
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi, I don't understand. Suddenly the code works and I have no idea why.
Thanks for your input guys! I will accept both your suggestions as solution.
@KrisD
Since you have conditions inside SWITCH, modify your formula as follows.
Replace SELECTEDVALUE ( 'Sammanstalling (2)' [Rank] ) with TRUE()
SWITCH ( TRUE() ,
'Sammanstalling (2)' [Rank] = 12 , [Gra..
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@KrisD
I would suggest you create some sample data in Excel with expected results in the column and share it here so a correct solution can be found.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi!
I can't use TRUE since I need to produce a number for each row (every value in col 1) and TRUE will stop comparing after the first true result.
@KrisD , There two way you use switch
Switch( selectedvalues([column]) ,
"11", "Abc",
"12", "DEF"
)
Switch( true() ,
selectedvalues([column]) = "11", "Abc",
selectedvalues([column]) = "12", "DEF"
)
refer my video
Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56
Hi!
Hi!
I can't use TRUE since I need to produce a number for each row (every value in col 1) and TRUE will stop comparing after the first true result.
The result in col 3 needs to be a number produced from my measure.