Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Cary_Casey
Frequent Visitor

If x contains any lower case letter, then y

Hello,

 

It would be awesome for the solution to be inside power query.

 

I have a data set where all of column X should have capital letters. If there is a lowercase letter, then there is a user error.

 

My goal is to identify those that have this error among others inside a dashboard.

 

Example:

XY
NIF15181SK0
NIF15171SK0
NIF15182SK0
NIf15182SKSP Error

 

Highlighted the error here on the 'f' in the last row.

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @Cary_Casey 

this is pretty easy to check in the query editor. Just add a column with this formula:

 

[X] = Text.Upper([X])

 

it compares if the content of column [X] matches its "uppercased" version 

 

Full code to follow along:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vN0MzQ1tDAM9laK1YFxzVG5FkZwbhqcGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [X = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"X", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Test", each [X] = Text.Upper([X]))
in
    #"Added Custom"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

2 REPLIES 2
ImkeF
Super User
Super User

Hi @Cary_Casey 

this is pretty easy to check in the query editor. Just add a column with this formula:

 

[X] = Text.Upper([X])

 

it compares if the content of column [X] matches its "uppercased" version 

 

Full code to follow along:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8vN0MzQ1tDAM9laK1YFxzVG5FkZwbhqcGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [X = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"X", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Test", each [X] = Text.Upper([X]))
in
    #"Added Custom"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF 

Thanks this works perfectly.

 

Such a simple solution. Can't believe I didn't think of that!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.