Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
Ykankam
Helper I
Helper I

switch not working correctly

I am using SWITCH function to get 4 different values. The first 3 works as expect, but the last condition does not return the expected value which is "Terminated". What could I be doing wrong?  Values from the highlighted column should be "Terminated".

switch 2.pngswitch 3.png

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@Ykankam ,

The SWITCH function works in sequence.  If it doesn't find Condition 1, it moves to the next.

My assumption here, without seeing all of the columns in your dataset, is that all of the conditions for "In Progress" are being met, so the SWITCH never reaches Condition 4 for "Terminated".

Try moving the "Terminated" Condition to be the 1st or 2nd and see if that resolves your issue.

Regards,

View solution in original post

3 REPLIES 3
tackytechtom
Super User
Super User

Hi @Ykankam ,

 

The BLANK() would kick in, if your column was null. In the screenshot, however, it appears that the value is an empty string.


What happens, if you try:

&& [Release_On_Time] = "" && [Complete_On Time] = ""

 

Does it work? 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

@tackytechtom thanks for your input. Since SWICTH works in a sequencial order, i had to place the terminated condition first. Code now looks like as shown below

GoldenBatch =
SWITCH (
    TRUE (),
    [termstatus] = "Term", "Terminated",
    [thaw_onTime] = "Y"
        && [proA_onTime] = "Y"
        && [BDS_onTime] = "Y"
        && [harvest_onTime] = "Y"
        && [%RFT_RFT] = "Y"
        && [titer_inFull] = "Y"
        && [yield_inFull] = "Y"
        && [deviation_RFT] = "Y", "Golden Batch",
    [thaw_onTime] = "N"
        || [proA_onTime] = "N"
        || [BDS_onTime] = "N"
        || [harvest_onTime] = "N"
        || [%RFT_RFT] = "N"
        || [titer_inFull] = "N"
        || [yield_inFull] = "N"
        || [deviation_RFT] = "N", "Miss",
    [thaw_onTime] = BLANK ()
        || [proA_onTime] = BLANK ()
        || [BDS_onTime] = BLANK ()
        || [harvest_onTime] = BLANK ()
        || [%RFT_RFT] = BLANK ()
        || [titer_inFull] = BLANK ()
        || [yield_inFull] = BLANK ()
        || [deviation_RFT] = BLANK (), "In Progress"
)
rsbin
Super User
Super User

@Ykankam ,

The SWITCH function works in sequence.  If it doesn't find Condition 1, it moves to the next.

My assumption here, without seeing all of the columns in your dataset, is that all of the conditions for "In Progress" are being met, so the SWITCH never reaches Condition 4 for "Terminated".

Try moving the "Terminated" Condition to be the 1st or 2nd and see if that resolves your issue.

Regards,

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.