Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Blanks with Switch Function

Hi All,

 

I have created a below calculated column where I want my Blnks to be treated as "Active" records but somehow they are getting captured as "Not Active". I'm not ablwe to get to the issue here.

 

Should I use If function instead of SWTICH here?

 

Need: When 

COMPLETED_ASSESSMENTS_LAST_30_DAYS = 0 then it is "Not Active" and when 
COMPLETED_ASSESSMENTS_LAST_30_DAYS  >0 or blank/null then it is "Active"

 

 

  • Hi Anonymous - Switch is more effective than if. you can adjust your calculated column to treat blanks as "Active" using below logic:

     

    Status =
    SWITCH(
    TRUE(),
    ISBLANK('YourTable'[COMPLETED_ASSESSMENTS_LAST_30_DAYS]), "Active",
    'YourTable'[COMPLETED_ASSESSMENTS_LAST_30_DAYS] = 0, "Not Active",
    'YourTable'[COMPLETED_ASSESSMENTS_LAST_30_DAYS] > 0, "Active",
    "Unknown"
    )

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

3 Replies

  • Hi Anonymous - Switch is more effective than if. you can adjust your calculated column to treat blanks as "Active" using below logic:

     

    Status =
    SWITCH(
    TRUE(),
    ISBLANK('YourTable'[COMPLETED_ASSESSMENTS_LAST_30_DAYS]), "Active",
    'YourTable'[COMPLETED_ASSESSMENTS_LAST_30_DAYS] = 0, "Not Active",
    'YourTable'[COMPLETED_ASSESSMENTS_LAST_30_DAYS] > 0, "Active",
    "Unknown"
    )

     

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!

    • Anonymous's avatar
      Anonymous
      Not applicable

      rajendraongole1 Thanks it worked but I'm curious to know why BLANK() function did not work and ISBLANK worked. Is it becasue of the boolean logic with BLANK() function?

       

      I actually got the desired result using IF condition as well:

      Activity Completed L30D1 =
      IF (
          ISBLANK(VW_NSM_AA[COMPLETED_ASSESSMENTS_LAST_30_DAYS]) || VW_NSM_AA[COMPLETED_ASSESSMENTS_LAST_30_DAYS] > 0,
          "Active",
          "Not Active"
      )
      • rajendraongole1's avatar
        rajendraongole1
        Super User

        Hi Anonymous - Yes correct, BLANK function, which returns a measure result as a null value, and ISBLANK, which is a logical function that returns a Boolean result.

         

        Did I answer your question? Mark my post as a solution! This will help others on the forum!
        Appreciate your Kudos!!