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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
PooBIDeveloper
Frequent Visitor

Default value in M Query

Hi All,

 

I have a column where a value is fixed,i am using custom column for this,but its showing error.

Below is the Query where i am trying to make a validation in the column if it has the value Z then its valid else invalid.

 

if
List.Contains({"Z"})
then "Valid"
else "Invalid"

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This should be done with Text.Contains instead of List.Contains:

 

= Table.AddColumn(PriorTableOrStepName, "Validator", each if Text.Contains([Column1], "Z") then "Valid" else "Invalid", type text)

 

--Nate

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

This should be done with Text.Contains instead of List.Contains:

 

= Table.AddColumn(PriorTableOrStepName, "Validator", each if Text.Contains([Column1], "Z") then "Valid" else "Invalid", type text)

 

--Nate

Vera_33
Resident Rockstar
Resident Rockstar

Hi @PooBIDeveloper 

 

So you are trying to see this paticular column has at least 1 Z?

Vera_33_0-1645249438975.png

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

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors