Forum Discussion

Villeminl's avatar
Villeminl
Regular Visitor
4 years ago
Solved

SUMIFS functionality using Power Query M advanced editor

Hello all, in need of some help to recreate the functionality of this SUMIFS formula. I'm still new on M Code and I'm really struggling with this one. I'm using this SUMIFS to compute a running total...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Villeminl 

     

    My guess is your column [LAST TOUCHED] is added after step #"Changed Type", you are now calling it in this table which the column has not yet existed...so let's call the step to add [LAST TOUCHED] as "step1" for now, then it should be like this

    = [CurID = [PART_ID],
    CurOp=[COUNT_REL_OPERATION],
    CurQty=[COMPLETED_QTY],
    CurDate=[DUE DATE],
    CurTouch=[LAST TOUCHED],
    res=List.Sum(
    Table.SelectRows(step1, each [PART_ID]=CurID and [COUNT_REL_OPERATION] =CurOp and [COMPLETED_QTY] = CurQty and DateTime.Date([DUE DATE]) = CurDate and [LAST TOUCHED] < CurTouch)
    [QTY])][res]

     

    As AlexisOlson mentioned, if it is slow, especially if you have lots of data, you should look for alternative ways. BUT, still, you can take it as a chance to learn, a step in M can be a table, a list, a parameter...etc

     

    I've sent you my email, feel free if you need more help.