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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
brief001
Helper II
Helper II

Search function for specific value

I am looking for an M code for a calculated column.
The aim is to search for the value "Yes" in the Type column,
where the ID must be the same. If so, the value "Yes" must be displayed, otherwise a null value.

On the picture you see the two columns I have.
And the orange column is the calculated column I'm looking for.

Screenshot_22.jpg

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci9KTc1T0lGKTC1WitVB8BOTU9JSwCJBqSlAvl8+EqeiOAWi2ikntRTINzQyBnPDMzJLUpEMg/GhmmFcpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Type = _t]),
    #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"All", each _, type table [ID=nullable text, Type=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Measure", each if List.Contains([All][Type],"Yes") then "Yes" else null),
    #"Expanded All" = Table.ExpandTableColumn(#"Added Custom", "All", {"Type"}, {"Type"})
in
    #"Expanded All"

View solution in original post

2 REPLIES 2
brief001
Helper II
Helper II

I would never have come up with this myself. Your example was already successful. Now I'm going to apply it to my actual data table.

Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci9KTc1T0lGKTC1WitVB8BOTU9JSwCJBqSlAvl8+EqeiOAWi2ikntRTINzQyBnPDMzJLUpEMg/GhmmFcpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Type = _t]),
    #"Grouped Rows" = Table.Group(Source, {"ID"}, {{"All", each _, type table [ID=nullable text, Type=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Measure", each if List.Contains([All][Type],"Yes") then "Yes" else null),
    #"Expanded All" = Table.ExpandTableColumn(#"Added Custom", "All", {"Type"}, {"Type"})
in
    #"Expanded All"

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.