Forum Discussion

StoryofData's avatar
StoryofData
Helper III
3 years ago
Solved

CountIf Multiple Columns

I need to combine two columns IF the other two equal to values I specified, it doesn't calculate properly, I am assuming this is due to &&, I tried || instead but it's still incorrect. What I am doi...
  • PhilipTreacy's avatar
    3 years ago

    Hi StoryofData 

     

    Download example PBIX file

     

    You can write this 

     

    Result = IF([Col A] = "Subject" && ([Col B] = "Substantiated" || [Col B] = "Unsubstantiated" || [Col B] = "Insufficient Data"), [Col D]&"-"&[Col C])

     

     

    But when you have multiple options to match for an OR condition you can also use the IN function which is a little neater

     

    Result = IF([Col A] = "Subject" && ([Col B] IN {"Substantiated" , "Unsubstantiated" , "Insufficient Data"}), [Col D]&"-"&[Col C])

     

     

     

    Regards

     

    Phil