Forum Discussion

L70F's avatar
L70F
Helper II
5 years ago
Solved

Conditional match to the reference table in Excel Power Query

Hi,  I need help with M-codes to Excel Power Query. I have a list of items with com.codes and reference table with responsible people for different com.groups. I would like to have the result, whe...
  • Anonymous's avatar
    Anonymous
    5 years ago

    this solution requires no changes to the item table

     

     

     

    let
        Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc0xDoAwDAPAv2REHVynCXRkQDwAtqr//wYplRCjT7bcmtxHwWWEJNEM6alJRXZuAcXshf10JXLIKA6xCp0Vn0BqgQcsXyQjAr/BGuDjpD8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Iten no" = _t, Com.code = _t]),
        #"Modificato tipo" = Table.TransformColumnTypes(Origine,{{"Iten no", type text}, {"Com.code", type text}}),
        #"Aggiunta colonna personalizzata" = Table.AddColumn(#"Modificato tipo", "resp", each let l= Table.SelectRows(respons, (r)=> 
              Text.StartsWith(r[Com.group], Text.Start([Com.code],1)))[Responsible], sp = if List.Count(l)=1 then l{0} else Table.SelectRows(respons, (r)=> 
              Text.StartsWith(r[Com.group], Text.Start([Com.code],2)))[Responsible]{0} in sp)
    in
        #"Aggiunta colonna personalizzata"