Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have a table:
I would like to take the first value of ID and prorate between the same IDs. Thus:
ID | DESCONTO | FRETE |
1 | 6,66 | 0 |
1 | 6,66 | 0 |
1 | 6,66 | 0 |
2 | 0 | 3,42 |
2 | 0 | 3,42 |
2 | 0 | 3,42 |
2 | 0 | 3,42 |
Thanks for your any help.
Solved! Go to Solution.
@credencial try this
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyABIGSrE6hLhGYJaOkqGxnpkFuSKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, val1 = _t, val2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"val1", Int64.Type}, {"val2", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"id"}, {{"ar", each _, type table [id=nullable number, val1=nullable number, val2=nullable number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "val1", each let x =[ar],
y =x[val1],
y1= List.Count(y),
z = List.Repeat({List.Distinct(y){0}/y1},y1)
in z),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "val2", each let x =[ar],
y =x[val2],
y1= List.Count(y),
z = List.Repeat({List.Distinct(y){0}/y1},y1)
in z),
#"Removed Columns1" = Table.RemoveColumns(#"Added Custom1",{"ar"}),
#"Added Custom2" = Table.AddColumn(#"Removed Columns1", "Custom", each Table.FromColumns({[val1],[val2]})),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"val1", "val2"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Column1", "Column2"}, {"Column1", "Column2"})
in
#"Expanded Custom"
@credencial try this
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyABIGSrE6hLhGYJaOkqGxnpkFuSKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, val1 = _t, val2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"val1", Int64.Type}, {"val2", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"id"}, {{"ar", each _, type table [id=nullable number, val1=nullable number, val2=nullable number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "val1", each let x =[ar],
y =x[val1],
y1= List.Count(y),
z = List.Repeat({List.Distinct(y){0}/y1},y1)
in z),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "val2", each let x =[ar],
y =x[val2],
y1= List.Count(y),
z = List.Repeat({List.Distinct(y){0}/y1},y1)
in z),
#"Removed Columns1" = Table.RemoveColumns(#"Added Custom1",{"ar"}),
#"Added Custom2" = Table.AddColumn(#"Removed Columns1", "Custom", each Table.FromColumns({[val1],[val2]})),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"val1", "val2"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Column1", "Column2"}, {"Column1", "Column2"})
in
#"Expanded Custom"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.