Forum Discussion
Ayuda Lookvalue de resultados multiple
- 5 years ago
Hi, RicardoLeivaG
Based on your description, I created data to reproduce your scneario. The pbix file is attached in the end.
Historic Header:
Historic datelle:
Here are the m codes for each Query.
Historic Header:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hcsxCsAgDIXhu2QWYhIS9QKFLnVwKYj3v0aD0CIuzZT3w9c71Jb8IABF5IIcOfq4DxLTvOd2wgjTqKnvgpQWwjrJWj9hLObbkHUVonv9EcJW/MtI9tarwhgP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Orden = _t, #"fecha Orden" = _t, #"Cod Invoice" = _t, #"Fcha Invoice" = _t, #"Cumple plazo entregra" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Orden", type text}, {"fecha Orden", type date}, {"Cod Invoice", type text}, {"Fcha Invoice", type date}, {"Cumple plazo entregra", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Orden"}, {{"Result", each Table.Max(_,"Fcha Invoice"), type table [Orden=nullable text, fecha Orden=nullable date, Cod Invoice=nullable text, Fcha Invoice=nullable date, Cumple plazo entregra=nullable text]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [Result][Fcha Invoice]), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each [Result][Cumple plazo entregra]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Result", "Custom"}) in #"Removed Columns"Historic datelle:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8g82BwIlHSVDA30jS30jAyMDIKckMScxpSgfJAzFwZ5KsTpg5aZmpkC+pb6hOUx1bmJRSWZODkg5mG8IUuDnD9VgZmRsBuSb6RuZwo3PzwWbbQQj4KZDFVvoG5rBTU8tTlRISVVISsxLBukyhboIZEEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Orden = _t, #"fcha Orden" = _t, Articulo = _t, #"cantidad ordenada" = _t, #"cantidad facturada" = _t, #"cumple despacho" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Orden", type text}, {"fcha Orden", type date}, {"Articulo", type text}, {"cantidad ordenada", Int64.Type}, {"cantidad facturada", Int64.Type}, {"cumple despacho", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Orden"}, {{"Result", each Table.Max(_,"fcha Orden"), type table [Orden=nullable text, fecha Orden=nullable date, Articulo=nullable text, cantidad ordenada=nullable number, cantidad facturada=nullable number, cumple despacho=nullable text]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Fcha Orden", each [Result][fcha Orden]), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Cumple despacho", each [Result][cumple despacho]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Result", "Fcha Orden"}) in #"Removed Columns"Query1:
let Query1 = let Source1 = #"Historic Header", Source2 = #"Historic datelle", tab = Source1 in Source1, #"Added Custom" = Table.AddColumn(Query1, "Custom", each let orden = [Orden], x = Table.First( Table.SelectRows(#"Historic datelle",each [Orden]=orden))[Cumple despacho] in x), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.2", each if [Custom.1]="NO" or [Custom]="NO" then "NO" else "SI") in #"Added Custom1"Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, RicardoLeivaG
Based on your description, I created data to reproduce your scneario. The pbix file is attached in the end.
Historic Header:
Historic datelle:
Here are the m codes for each Query.
Historic Header:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hcsxCsAgDIXhu2QWYhIS9QKFLnVwKYj3v0aD0CIuzZT3w9c71Jb8IABF5IIcOfq4DxLTvOd2wgjTqKnvgpQWwjrJWj9hLObbkHUVonv9EcJW/MtI9tarwhgP", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Orden = _t, #"fecha Orden" = _t, #"Cod Invoice" = _t, #"Fcha Invoice" = _t, #"Cumple plazo entregra" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Orden", type text}, {"fecha Orden", type date}, {"Cod Invoice", type text}, {"Fcha Invoice", type date}, {"Cumple plazo entregra", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Orden"}, {{"Result", each Table.Max(_,"Fcha Invoice"), type table [Orden=nullable text, fecha Orden=nullable date, Cod Invoice=nullable text, Fcha Invoice=nullable date, Cumple plazo entregra=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [Result][Fcha Invoice]),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each [Result][Cumple plazo entregra]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Result", "Custom"})
in
#"Removed Columns"
Historic datelle:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8g82BwIlHSVDA30jS30jAyMDIKckMScxpSgfJAzFwZ5KsTpg5aZmpkC+pb6hOUx1bmJRSWZODkg5mG8IUuDnD9VgZmRsBuSb6RuZwo3PzwWbbQQj4KZDFVvoG5rBTU8tTlRISVVISsxLBukyhboIZEEsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Orden = _t, #"fcha Orden" = _t, Articulo = _t, #"cantidad ordenada" = _t, #"cantidad facturada" = _t, #"cumple despacho" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Orden", type text}, {"fcha Orden", type date}, {"Articulo", type text}, {"cantidad ordenada", Int64.Type}, {"cantidad facturada", Int64.Type}, {"cumple despacho", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Orden"}, {{"Result", each Table.Max(_,"fcha Orden"), type table [Orden=nullable text, fecha Orden=nullable date, Articulo=nullable text, cantidad ordenada=nullable number, cantidad facturada=nullable number, cumple despacho=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Fcha Orden", each [Result][fcha Orden]),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Cumple despacho", each [Result][cumple despacho]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Result", "Fcha Orden"})
in
#"Removed Columns"
Query1:
let
Query1 = let
Source1 = #"Historic Header",
Source2 = #"Historic datelle",
tab = Source1
in
Source1,
#"Added Custom" = Table.AddColumn(Query1, "Custom", each let orden = [Orden],
x = Table.First( Table.SelectRows(#"Historic datelle",each [Orden]=orden))[Cumple despacho]
in
x),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.2", each if [Custom.1]="NO" or [Custom]="NO" then "NO" else "SI")
in
#"Added Custom1"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years agoNot applicable
Hi RicardoLeivaG ,
Slightly modified to meet your requirements:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQr2VIrViVYyQjCNUZl+/kqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Value1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Value1", type text}}), //Add this line - this is to provide logical AND for all items under one order #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Value1", (x)=> x[Value1]{List.PositionOf(x[ID], List.Max(x[ID]))}}}) in #"Grouped Rows"let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrOVIrViVYyAjL98sFMY4SoMVQ0FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Value2 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Value2", type text}}), //Add this line - this is to provide logical AND for all items under one order #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Value2", (x)=> x[Value2]{List.PositionOf(x[ID], List.Max(x[ID]))}}}) in #"Grouped Rows"Just change Value1 & Value2 to your values and ID (which we do LIst.Max for to your date field.
Kind regards,
JB