Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to create subcategory

Hello,

 

modeloperatingSystem
HoloLensWindows
UC-EngineWindows
UC-EngineWindows

 

so if the model equals UC-Engine I would like to change the value of operatingSystem to something new.

How do I do this? I dont want to create a new column or table for that, just replace the values and leave all the other values where model is not UC-Engine.

Thank you very much!

  • Hi, Anonymous ;

    You could add  a condtion column in power query then delete original column.

    1.add new column.

    = Table.AddColumn(#"Changed Type", "operatingSystem2", each if [model] = "UC-Engine" then  "new" else [operatingSystem])

    2.delete original column,

    The final output is shown below:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sjPyfdJzStW0lEKz8xLyS8vVorViVYKddZ1zUvPzEslRjwWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [model = _t, operatingSystem = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"model", type text}, {"operatingSystem", type text}}),
        #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "operatingSystem2", each if [model] = "UC-Engine" then  "new" else [operatingSystem]),
        #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"operatingSystem"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"operatingSystem2", "operatingSystem"}})
    in
        #"Renamed Columns"


    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      What do I have to do?

       

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, Anonymous ;

    You could add  a condtion column in power query then delete original column.

    1.add new column.

    = Table.AddColumn(#"Changed Type", "operatingSystem2", each if [model] = "UC-Engine" then  "new" else [operatingSystem])

    2.delete original column,

    The final output is shown below:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sjPyfdJzStW0lEKz8xLyS8vVorViVYKddZ1zUvPzEslRjwWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [model = _t, operatingSystem = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"model", type text}, {"operatingSystem", type text}}),
        #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "operatingSystem2", each if [model] = "UC-Engine" then  "new" else [operatingSystem]),
        #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"operatingSystem"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"operatingSystem2", "operatingSystem"}})
    in
        #"Renamed Columns"


    Best Regards,
    Community Support Team_ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.