Forum Discussion

pelucapampa's avatar
pelucapampa
Icon for Helper I rankHelper I
7 years ago

Sum by Value in other Column

Hi All, how are you?? I need some help.

 

I've a table with some columns

 

DateOrganizationTypeRazonSocial
01/11/2017 PARTICULAR
01/04/2016CORPORATIVO​​CLEO INFORMACION ESPECIALIZADA SRL
01/04/2017CORPORATIVO​​CLEO INFORMACION ESPECIALIZADA SRL
01/10/2016 PARTICULAR

 

I need to replace OrganizationType with "DIRECT" when RazonSocial have "PARTICULAR". 

 

I tried with Table.ReplaceValue, but i couldn't make it.

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    You could always do something like this:

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3NNQ3MjA0V9JRAqIAx6AQT+dQH8cgpVgdkKwJSNIMKOPsHxTgH+QY4hnmD+Q9augGImcfV38FTz83/yBfR2dPfz8F1+AAV2dPRx/PKEcXR4XgIB9kU8wpNcXQAOYYNJfGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, OrganizationType = _t, RazonSocial = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"OrganizationType", type text}, {"RazonSocial", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [RazonSocial] = "PARTICULAR" then "DIRECT" else [OrganizationType]),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"OrganizationType"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "OrganizationType"}})
    in
        #"Renamed Columns"