Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
credencial
Frequent Visitor

Apportionment of values based ID

Hi,

I have a table:

 

credencial_0-1634244295079.png

 

I would like to take the first value of ID and prorate between the same IDs. Thus:

 

IDDESCONTOFRETE
16,660
16,660
16,660
203,42
203,42
203,42
203,42

 

Thanks for your any help.

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@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"

 

 

smpa01_0-1634247549693.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

1 REPLY 1
smpa01
Super User
Super User

@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"

 

 

smpa01_0-1634247549693.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors