Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
10 | |
10 | |
8 | |
7 |