Forum Discussion
Simon_1981
1 year agoFrequent Visitor
Return a value after checking two values within the right ranges
Hi, I am trying to figure out how to get the right value (i.e. Color) from a weight / volume table in a products table with power query M. The returned value (color) needs to meet both criteria, th...
- 1 year ago
Hi Simon,
Your direction is right, and overall you can implement that by
1. add a column holding the corresponding Numbers records
2. expand that newly added column which holds records and pick the Color column
let
Numbers = Excel.CurrentWorkbook(){[Name="Numbers"]}[Content],
Product = Excel.CurrentWorkbook(){[Name="Product"]}[Content],
#"Add ColorTable Col" = Table.AddColumn(Product, "ColorTable",
(ProdRow as record) =>
Table.SelectRows(
Numbers,
each [Weight from] <= ProdRow[Weight] and ProdRow[Weight] <= [Weight to]
and [Volume from] <= ProdRow[Volume] and ProdRow[Volume] <= [Volume to]
)
),
#"Expand Col" = Table.ExpandTableColumn(#"Add ColorTable Col", "ColorTable", {"Color"})
in
#"Expand Col"
Simon_1981
1 year agoFrequent Visitor
Good morning Claude_Xu,
you made it look so easy. Thank you so much for your help and for your solution -that's awesome!
Many regards,
Simon