Forum Discussion
Validate & Limit Numbers and Characters using Measure
- 4 years ago
Download this PBIX file with the following code
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNnEMDzRWitWBcEzNzC1QOJYGhhC+sZGXh7eFOZhjYW7mZWlhbgnmRIYEuUe6e3h5K8XGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Field = _t]), #"Added Custom" = Table.AddColumn(Source, "Result 1", each if Text.Length([Field]) = 10 and List.ContainsAny(Text.ToList(Text.Lower([Field])), {"a..z"}) and List.ContainsAny(Text.ToList(Text.Lower([Field])), {"0..9"}) then true else false), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Result 2", each if Text.Length([Field]) >= 8 and Text.Length([Field]) <= 12 and List.ContainsAny(Text.ToList(Text.Lower([Field])), {"a".."z"}) and List.ContainsAny(Text.ToList(Text.Lower([Field])), {"0".."9"}) then true else false), #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Result 3", each if Text.Length([Field]) = 12 then if List.ContainsAny(Text.ToList(Text.Lower([Field])), {"a".."z"}) then false else true else false), #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Result 4", each if Text.Length([Field]) = 12 then if List.ContainsAny(Text.ToList(Text.Lower([Field])), {"0".."9"}) then false else true else false) in #"Added Custom3"Regards
Phil
OK, but do you have separate columns for each of these types of inputs? Or are the columns made up of mixed field types, that is, some fields in the column are Type 1 : Alphanumeric and 10 characters, and some fields are Type 4 : Letters only and must be 12 characters?
If so, how do you distinguish between the fields? Power Query won't know which field is which type.
How do you want the results flagged? A single column with all errors in it, or one error column for each different type of field?
Please suypply more complete sample data and an example of your expected result/output.
Regards
Phil
- gauravnarchal4 years agoPost Prodigy
Hi PhilipTreacy - I want to display the result "Single column with all errors"
Below is the
Field Result 1 Result 2 Result 3 Result 4 1234AWQ3 FALSE TRUE FALSE FALSE 12345678 FALSE FALSE FALSE FALSE 12345678901 FALSE FALSE FALSE FALSE 132JHK87 FALSE TRUE FALSE FALSE 876J9879 FALSE TRUE FALSE FALSE YTRGYGHJK FALSE FALSE FALSE FALSE