Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Rigoleto
Helper II
Helper II

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?

 

Imagen99.png

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
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

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Employee
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

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.