Forum Discussion
Mp1977
Helper II
6 years agoReplace value with a value from other column
Hi guys, can someone help me out with the following problem? I have a Excel table that has the month valued merged for 3 columns and I need it in the Total Cell. What I Have in power query ...
- 6 years ago
Try this:
let Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("vZA9C8IwFEX/SshctU21H27aqiBYBQsO6hC0aDFNoDRDEf+7HbR9L3QUx9zcyzm845NGSuhCOnRKpRaCWp+AmYFrBuMmWCkuyIDsF7vTiNnt18Tsembgd+NtlKJxYHbDb/CyoG6ihsg24UWGbJdaXqpcSWQc81zU5Nagke1BlY/sSmJeI+dUVRxL9+yD/n3Y7pG3A503vKyR8wzKOsCQecCre/ig1Xc4G7EZZK/VXf6R7UJ2JLhG7PnP2ec3", BinaryEncoding.Base64),Compression.Deflate))), transp = Table.Transpose(Source), group = Table.Group( transp, "Column1", { "t", (tbl)=> Table.ReplaceValue( tbl, each tbl[Column1]{0}, each [Column2]="Total", (x,y,z)=>if z then y else x, {"Column2"} ) }, 0, (x,y)=>Byte.From(Text.StartsWith(y, "Goal")) ), result = Table.Transpose(Table.Combine(group[t])) in result
Anonymous
6 years agoNot applicable
This type of report should be created in visuals in Power BI. The format of the table is wrong for data modeling as you'll soon discover. You should avoid such unwieldy constructs since they will give you a lot of grief and pain. Instead, you should work in agreement with the tools, not against them. The fact that something is doable, does not always mean it should be done. Judging by what you're trying to do, I think you should not do it. You should rather create a tidy table that's suitable for DAX calculations. Please read about tidy data: https://towardsdatascience.com/whats-tidy-data-how-to-organize-messy-datasets-in-python-with-melt-and-pivotable-functions-5d52daa996c9