Forum Discussion
Take maximum value from another table with duplicate values
- 5 years ago
Anonymous
Simple answer:
1. You didn't specify that
2. I didn't look in detail
Simplified version:
New column V2 = VAR auxT_ = CALCULATETABLE ( 'Reel defect', TREATAS ( CALCULATETABLE ( DISTINCT ( 'Reel status'[Key] ) ), 'Reel status'[Key] ) ) VAR maxLenT_ = TOPN ( 1, auxT_, [Length], DESC ) RETURN MAXX ( maxLenT_, [Fault code] )Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- 5 years ago
Anonymous
If you need it in PQ (which you didn't specify at the beginning either), place the following M code in a blank query to see the steps:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdFBCoUwDIThu3StYDOJ6FnE+1/jKbwWZ5KFFORb/J1eV9v67m1p/f/ZuW/P8f5d+9rbvRCxREwJEoEST8SVRCLxJTZz4xzEONdm7peYEiQCJZ6IK4lEKBfFuuBcFOuCc1GsC85FsS44F8W64NzxCMcxhXPtuDcJUwEVUOEqXEWoeErvHw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order = _t, #"Runup Sequence" = _t, Lane = _t, #"Reel Lenght" = _t, Key = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", type text}, {"Runup Sequence", Int64.Type}, {"Lane", Int64.Type}, {"Reel Lenght", Int64.Type}, {"Key", type text}}), #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Key"}, #"Reel defect", {"Key"}, "Reel defect", JoinKind.LeftOuter), #"Added Custom" = Table.AddColumn(#"Merged Queries", "Fault code", (input)=> try let max_ = List.Max(input[Reel defect][Length]), pos_ = List.PositionOf(input[Reel defect][Length], max_, Occurrence.First), res_ = input[Reel defect][Fault code]{pos_} in res_ otherwise null, type text), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Reel defect"}) in #"Removed Columns"Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
- 5 years ago
Anonymous
See it all at work in the attached file.
Please mark the question solved when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Anonymous , One is to merge in power query, if need create a concatenated key to have join and the get the required column
https://radacad.com/append-vs-merge-in-power-bi-and-power-query
In DAx Copy value from one table to another -https://www.youtube.com/watch?v=czNHt7UXIe8
example
maxx(filter(defect, defect[order] = status[order] && defect[runup sequence] = status[runup sequence] && defect[lane] = status[lane] && defect[key] = status[key]),defect[Fault code])
add remove column as per need in above
I looked at your formula again and did not find there sorting by the "length" parameter. Will it return the correct value for sure?