Forum Discussion
negi007
Community Champion
5 years agoImport Max Value Records from Source data
Hi All,
I have one master product table in AWS mysql DB. This table has below column and sample values
Index
Product ID
Value
1
PRD1
20
2
PRD2
40
3
P...
- 5 years ago
here a example of the needed statement:
Jimmy801
Community Champion
5 years agoHello negi007
you can use Table.Group to make this in power Query. However you have to check if query folding is talking place, otherwise you have to go for the solution of StefanoGrimaldi, and directly make a SQL statement. Here a code example
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlRQ0lEKCHIB00YGSrE60UpGUDEwbQIRM4aKGSOpM0HWawoRM0VWZwYRM0M2zxwoFgsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Index " = _t, #"Product ID " = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Index ", Int64.Type}, {"Product ID ", type text}, {"Value", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Product ID "}, {{"MaxValue", each Table.Max(_, "Value"), type record}}),
#"Expanded MaxValue" = Table.ExpandRecordColumn(#"Grouped Rows", "MaxValue", {"Index ", "Value"}, {"Index ", "Value"})
in
#"Expanded MaxValue"
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