Forum Discussion
Divous
4 years agoHelper III
RANKX with multiple FILTER
Hi community, I would like to add the order of support and users (see desired output). I manage to number the order according to the id and time columns with RANKX, but I no longer know how to ad...
v-kkf-msft
4 years agoCommunity Support
Hi Divous ,
If you use the M code in Power Query Editor and then create a calculated column, will you encounter memory problems this way?
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ndNBC4IwFAfwryI7C25v6rRbUIciSYIOJV6EIkVSNCH69Kl5Sd82GOwwGD/+7+1tSUIo9YvdI9rk8fFKbMLAAdovYBajKzosax31B1ZTZdWr3zy7siSpjUpmLAGVbVfXVTNYJoMchV17a1TK1cSBDHqqOKnyNXFcBoUpDFR1SlWoiXNHWBR0W2fvHA7iPJsCUw8ekS4q/+aHKA9V8+eCQN8UClMYqBr8vZhPdYn3oSfup1l7MJl4eSkL46NmXuCCCTMWqCqUdBVqonDGqRljqgo5YpxRgDwIRYCiKab/L+kX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, time_of_message = _t, who = _t, #"desired output" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", type text}, {"time_of_message", type datetime}, {"who", type text}, {"desired output", Int64.Type}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ","",Replacer.ReplaceText,{"who"}),
#"Grouped Rows" = Table.Group(#"Replaced Value", {"id"}, {{"All", each _, type table [id=nullable text, time_of_message=nullable datetime, who=nullable text, desired output=nullable number, Index=number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All],"IndexByid",1)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"id", "All"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"id", "time_of_message", "who", "desired output", "IndexByid"}, {"id", "time_of_message", "who", "desired output", "IndexByid"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Expanded Custom",{{"IndexByid", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type2", "Index", 1, 1, Int64.Type),
#"Added Custom1" = Table.AddColumn(#"Added Index", "Custom", each if [who] = "robot" then null
else if [IndexByid] = 1 then 1
else if
[who] <> (try #"Added Index"{[Index]-2}[who] otherwise null) then 1
else 0),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", Int64.Type}})
in
#"Changed Type1"
Output =
CALCULATE (
SUM ( 'Table'[Custom] ),
FILTER (
'Table',
'Table'[IndexByid] <= EARLIER ( 'Table'[IndexByid] )
&& 'Table'[id] = EARLIER ( 'Table'[id] )
&& 'Table'[who] = EARLIER ( 'Table'[who] )
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.