cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
newgirl
Helper IV
Helper IV

M language Maximum Value

Hi!

 

I have a "Text after delimeter" column that shows 3 values - 20, 21, and B. I want to add another column in the Query Editor that if the value is B, it should instead show whatever is the maximum value from the "Text after delimeter" column.

 

Would appreciate the help!

 

opexx.JPG

1 ACCEPTED SOLUTION
FrankAT
Super User II
Super User II

Hi @newgirl ,

you can do it like this:

 

06-05-_2021_16-12-06.png

 

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjJQitUBUoZgygnCQWIbWirFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Text After Delimiter" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Only numbers", each try Number.From([Text After Delimiter]) otherwise null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Insert Max", each if [Only numbers] <> null then [Only numbers] else List.Max(#"Added Custom"[Only numbers])),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Only numbers", type number}, {"Insert Max", type number}})
in
    #"Changed Type"

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

View solution in original post

2 REPLIES 2
FrankAT
Super User II
Super User II

Hi @newgirl ,

you can do it like this:

 

06-05-_2021_16-12-06.png

 

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjJQitUBUoZgygnCQWIbWirFxgIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Text After Delimiter" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Only numbers", each try Number.From([Text After Delimiter]) otherwise null),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Insert Max", each if [Only numbers] <> null then [Only numbers] else List.Max(#"Added Custom"[Only numbers])),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Only numbers", type number}, {"Insert Max", type number}})
in
    #"Changed Type"

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

View solution in original post

Thank you so much! This worked!

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors