Forum Discussion

Rigoleto's avatar
Rigoleto
Helper II
8 years ago
Solved

Recalculate a column values

Hi,

 

I need to recalculate a column value, for instance

I have a column that is showing pices like a Units values, do I need is to recalculate the column and show the Units in Dozens and left the new value in the sam column.

The figure below shows the column Pieces produced, the second column DZ is the recalculated value in DZ, later I need to replace the DZ values in Pieces Produced, can I recaulculate it in running time, hitting button or slice selection?

 

  • Hi Rigoleto,

     

    Do you want to replace the values of [Pieces produced] with values of [DZ]? If so, you can use the Replacer.ReplaceValue function in Power Query.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIyMLTQNTAEIiDH0ABImCrF6iDLGUHkjEByhhZoksYQSWOQpJERWNIJw1RTEIEuCTUWaKKOkjmaHMxUsEZjpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Product = _t, Date = _t, Ind1 = _t, Ind2 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Date", type date}, {"Ind1", Int64.Type}, {"Ind2", Int64.Type}}),
        #"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Pieces produced],each _[DZ],Replacer.ReplaceValue,{"Pieces produced"})
    in
        #"Replaced Value"

    Be sure to use the " each _[Values Column]" syntax with the spaces before and after "each", otherwise you will get an error.

     

    Best regards,

    Yuliana Gu

1 Reply

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi Rigoleto,

     

    Do you want to replace the values of [Pieces produced] with values of [DZ]? If so, you can use the Replacer.ReplaceValue function in Power Query.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIyMLTQNTAEIiDH0ABImCrF6iDLGUHkjEByhhZoksYQSWOQpJERWNIJw1RTEIEuCTUWaKKOkjmaHMxUsEZjpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Product = _t, Date = _t, Ind1 = _t, Ind2 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Date", type date}, {"Ind1", Int64.Type}, {"Ind2", Int64.Type}}),
        #"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Pieces produced],each _[DZ],Replacer.ReplaceValue,{"Pieces produced"})
    in
        #"Replaced Value"

    Be sure to use the " each _[Values Column]" syntax with the spaces before and after "each", otherwise you will get an error.

     

    Best regards,

    Yuliana Gu