Tyler
Tyler

Reputation: 3

PowerBI M: How to code in an exclusion to an IF statement

I'm working to programmatically clean up a field in my dataset by using a Helper column that I will later filter on and remove the 'junk' records. The junk records are ID's, and the valid records are full names (in the format of "Tom Jones"). Almost all (there is a valid name value of "University") junk records do not contain a space. The pseudo code would read

Set Helper_IsName? = True
WHERE ValueField CONTAINS " " unless ValueField = "University"
ELSE False

Here is the M code excerpt that is getting me 95% of the way there:

Helper_IsName? = Text.Contains([OldValue]," ")

All results are good, except when the formula reads "University", it sets the value as FALSE, when I need it to equal TRUE.

Upvotes: 0

Views: 127

Answers (1)

Alexis Olson
Alexis Olson

Reputation: 40204

I think you can just add that condition with an or:

Helper_IsName? = Text.Contains([OldValue]," ") or [OldValue] = "University"

Upvotes: 1

Related Questions