Forum Discussion

Roodakker's avatar
Roodakker
Frequent Visitor
2 years ago
Solved

Change name on duplicates in the same ID

Hi, I'm a rookie at M and need help! 

 

I'm preparing data for process mining and unfortunatley the process use the same status "14 - Approved" multiple times per ID. If possible, it would be great if I somehow could rename the second use of the status per ID to "14 - ODD Approved". 

 

I've tried this M-formula to create a count of status 14 and based on the occurance rename the second one.

 

let
Source = Excel.CurrentWorkbook [Content],

Custom = Table.Group(Source, {"Efecte ID", "[StatusHistoryRefined;14KYCApproved]"}, {{"Count", each Table.RowCount(_), type number}}),
AddedCustom = Table.AddColumn(Custom, "New Status", each if [Count] > 1 and [Count] = 2 then "14 - ODD KYC Approved" else [StatusHistoryRefined;14KYCApproved]),
RemovedColumns = Table.RemoveColumns(AddedCustom, {"Count", "[StatusHistoryRefined;14KYCApproved]"}),
ExpandCustom = Table.ExpandTableColumn(RemovedColumns, "New Status", {"Efecte ID", "New Status"})
in
ExpandCustom

 

But it won't recognize [StatusHistoryRefined;14KYCApproved] as identifier.

 

 

 

Is it possible to solve my problem? 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Roodakker 

    1.You can consider to add an index column  group by each id first , the step can refer to the following link.

    Create Row Number for Each Group in Power BI using Power Query - RADACAD

    2.Then add a custom column

    e.g(Then [Index] column is the one you have created above.

    if [Index]=2 then "14 - ODD KYC Approved" else [StatusHistoryRefined;14KYCApproved]

     

    Best Regards!

    Yolo Zhu

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

     

     

     

2 Replies