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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors