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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
martinblom
Regular Visitor

HELP Power Query Code - Formula for finding a text in a grouped column without expanding

Hello everyone,

 

I need your help to solve a problem.

 

This is my data:

martinblom_0-1666201852654.png

Step 1:

Grouped Rows by PersonID

martinblom_2-1666201937052.png

martinblom_1-1666201919909.png

 

Step 2:

Add Custom Column with the code: Table.Transpose(Table.SelectColumns([Antal], {"Betalingskanal"}))

martinblom_3-1666200812373.png

martinblom_2-1666200786943.png

 

Step 3:

Now what I want is something like this: - if [GOD] = "MOBILEPAY" then true else false, but it does not work.

It says false, but should be true.

martinblom_0-1666202479281.png

martinblom_1-1666202524351.png

I think it is because there are 13 columns, so I have to tell the formula, that I do not care what column it is, it has to take ALL columns, and look for the word inside the columns and see if it match with the word.

 

I hope you guys understand what I am trying.

 

OBS! I need to do all this without expanding the columns, it is very important. In my other query i got over 1 million ID's. You are not able to expand them all due to crashed, time etc.

 

Thank you very much for your help.


Best regards,

Martin

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @martinblom ,

According to your description, here's my solution.

Add a custom column.

if List.Contains([Antal][Betalingskanal],"MOBILEPAY") then "True" else "False"

I modify the sample to:

vkalyjmsft_0-1666231960011.png

And get the correct result:

vkalyjmsft_1-1666231988093.png

The whole M syatax is:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZC7CsJAEEX/ZetI5s5rd0oDEYKKgpWEFJaC/n/r2okGSbo5cA5cZhyTUpYCkGtqkmYJeCHOFY6nbjj05+213kzMLahFpKn5ioKMQyHZK3SXRba5vaHfPG/3x6JC2K3Cbtj/6uYKFrcSHzqwTuc/e2YLXV2IzX1oegE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PersonID = _t, AccountID = _t, Betalingskanal = _t, DWCreatedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"PersonID", Int64.Type}, {"AccountID", Int64.Type}, {"Betalingskanal", type text}, {"DWCreatedDate", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"PersonID"}, {{"Antal", each _, type table [PersonID=nullable number, AccountID=nullable number, Betalingskanal=nullable text, DWCreatedDate=nullable date]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if List.Contains([Antal][Betalingskanal],"MOBILEPAY") then "True" else "False")
in
    #"Added Custom"

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @martinblom ,

According to your description, here's my solution.

Add a custom column.

if List.Contains([Antal][Betalingskanal],"MOBILEPAY") then "True" else "False"

I modify the sample to:

vkalyjmsft_0-1666231960011.png

And get the correct result:

vkalyjmsft_1-1666231988093.png

The whole M syatax is:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZC7CsJAEEX/ZetI5s5rd0oDEYKKgpWEFJaC/n/r2okGSbo5cA5cZhyTUpYCkGtqkmYJeCHOFY6nbjj05+213kzMLahFpKn5ioKMQyHZK3SXRba5vaHfPG/3x6JC2K3Cbtj/6uYKFrcSHzqwTuc/e2YLXV2IzX1oegE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PersonID = _t, AccountID = _t, Betalingskanal = _t, DWCreatedDate = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"PersonID", Int64.Type}, {"AccountID", Int64.Type}, {"Betalingskanal", type text}, {"DWCreatedDate", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"PersonID"}, {{"Antal", each _, type table [PersonID=nullable number, AccountID=nullable number, Betalingskanal=nullable text, DWCreatedDate=nullable date]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each if List.Contains([Antal][Betalingskanal],"MOBILEPAY") then "True" else "False")
in
    #"Added Custom"

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.