Forum Discussion
Translating from Tableau to Power BI
Having a hard time converting this if then else statement into Power BI. I tried to do it using the Switch function but the results were showing up as 0.
Any help would be appreciated.
IF [Problem Type Name]="No Operator Available"
THEN [Minutes Lost]
ELSEIF [Problem Type Name]="Meeting"
THEN [Minutes Lost]
ELSEIF [Problem Type Name]="Admin Recode"
THEN [Minutes Lost]
ELSEIF [Problem Type Name]="Training"
THEN [Minutes Lost]
ELSEIF [Problem Type Name]= "Lunch" AND [Problem Planned] = TRUE
THEN [Minutes Lost]
elseif [Problem Type Name]= "Break" AND [Problem Planned] = TRUE
THEN [Minutes Lost]
ELSE 0
END
5 Replies
- amitchandak
Super User
Anonymous , Try like
Switch( True() ,
[Problem Type Name]="No Operator Available" , [Minutes Lost],
[Problem Type Name]="Meeting" , [Minutes Lost],
[Problem Type Name]="Admin Recode", [Minutes Lost],
[Problem Type Name]="Training" , [Minutes Lost],
[Problem Type Name]= "Lunch" && [Problem Planned] = TRUE() , [Minutes Lost],
[Problem Type Name]= "Break" && [Problem Planned] = TRUE() , [Minutes Lost],
0
)Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56
Tableau Vs Power BI: https://www.youtube.com/watch?v=tAmg00Wf_cw&list=PLPaNVDMhUXGYzjFASXjdY7GNoFxvlkR54
- AnonymousNot applicable
So what I tried is very similar. But the fields Problem type name, problem planned and minutes lost are all fields from a odbc data set.
So what I have is
SWITCH(TRUE(),SELECTEDVALUE(v_losses[problemTypeName])="No Operator Available",SUM(v_losses[minutesLost]),SELECTEDVALUE(v_losses[problemTypeName])="Meeting",SUM(v_losses[minutesLost]),SELECTEDVALUE(v_losses[problemTypeName])="Training",SUM(v_losses[minutesLost]),AND(SELECTEDVALUE(v_losses[problemTypeName])="Lunch",SELECTEDVALUE(v_losses[problemPlanned])="1"),SUM(v_losses[minutesLost]),AND(SELECTEDVALUE(v_losses[problemTypeName])="Break",SELECTEDVALUE(v_losses[problemPlanned])="1"),SUM(v_losses[minutesLost]),0)I know from Tableau that the result should be non-zero but i brings back zero.Any suggestions?
- v-xulin-mstf
Community Support
Hi Anonymous
Not sure about your data structure.
Could you provide the sample data and expected output in Power bi?Best Regards,
Link
Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!
- Tahreem24
Super User
Anonymous What did you use for your switch function? Measure or Calculated Column?
- AnonymousNot applicable
I was using it as a measure