Forum Discussion
Percentage between two columns
- 5 years ago
Hello gaikwadaa123
you can join both tables by the datetime column and then expand your F-Column and then the needed calculation
Here an example
let A = let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjAyNDBQNDKwMDJR0lQ6VYHVQJI4iEkVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateTime = _t, #"DBDryBulb-A" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime}, {"DBDryBulb-A", Int64.Type}}, "de-DE") in #"Changed Type", B= let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjAyNDBQNDKwMDJR0lY6VYHVQJI4iEiVJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DateTime = _t, #"DBDryBulb-F" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetime}, {"DBDryBulb-F", Int64.Type}}, "de-DE") in #"Changed Type", JoinTables= Table.NestedJoin ( A, "DateTime", B, "DateTime", "B", JoinKind.LeftOuter ), #"Expanded B" = Table.ExpandTableColumn(JoinTables, "B", {"DBDryBulb-F"}, {"DBDryBulb-F"}), #"Added Custom" = Table.AddColumn(#"Expanded B", "Custom", each ([#"DBDryBulb-A"]-[#"DBDryBulb-F"])/[#"DBDryBulb-A"]) in #"Added Custom"Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy - 5 years ago
Hi gaikwadaa123 ,
After merging two tables, please detect the data type for each column, if the data type is wrong, it could cause the wrong calculation result.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Can you describe your model further? Do you have separate tables for DateTime values? One with your Sensors(?) ID values? I would encourage you to add both those tables if not already, so you can connect to the two tables you show above. If the columns are the same in both F and A tables, you could also consider appending them (with a column to indicate if it is an F or A value). Either of the above suggestions would make your calculation simpler.
Pat