Forum Discussion
gauravnarchal
4 years agoPost Prodigy
Validate & Limit Numbers and Characters using Measure
Dear All - I have a field in my data that I want to validate & Limit Numbers and Characters I want to achieve the below by creating separate measures. The Alphanumeric Field accepts values only...
- 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
PhilipTreacy
4 years agoSuper User
You can't restrict/prevenmt data entry like this. The user can enter whatever they want (subject to any restriuctions in the data entry point) but PBI/Power Query/DAX can only test the data after it's been entered and flag problems. Is that what you want?
Regards
Phil
gauravnarchal
4 years agoPost Prodigy