Forum Discussion
krishma
2 years agoRegular Visitor
Power BI Desktop query
There are two tables which are mapped on the basis of name: table 1 name type ram a shaym b kiran a anglea b david c angha a arpitha b ...
- 2 years ago
You can do this in Power Query.
Group the the table with the types by name choosing all rows to get a nested table per name.
Merge by Name with the money query.
Expand the merge to get the money column
Add a column to get the row count of the nested tables.
Table.AddColumn(PREVIOUSSTEP, "nestedRowCount", each Table.RowCount([_nestedTable]), Int64.Type)Replace the values in the money column with the money value divided by the nested row count.
Table.ReplaceValue(PREVIOUSSTEP,each [money],each [money]/[nestedRowCount],Replacer.ReplaceValue,{"money"})Remove the nestedRowCount column
expand the nested table type column only.
You should get something like...
- 2 years ago
Table 1
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkrMVdJRSlSK1YlWKs5IrATxksC87MyixDy4XGJeek5qIlwyJbEsMwXIS4ZJZiQilBYVZJZkINRCrEA1NBnFFKC+WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [name = _t, #"type" = _t]), #"Added Custom" = Table.AddColumn(Source, "money I want to come", (k)=> Table.SelectRows(#"Table 2",each [name]=k[name]){0}[money]/List.Count(List.Select(Source[name],each _=k[name]))) in #"Added Custom"
krishma
2 years agoRegular Visitor
amitchandak lbendlin Ashish_Mathur Ritaf1983
please help
lbendlin
2 years agoSuper User
Table 1
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkrMVdJRSlSK1YlWKs5IrATxksC87MyixDy4XGJeek5qIlwyJbEsMwXIS4ZJZiQilBYVZJZkINRCrEA1NBnFFKC+WAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [name = _t, #"type" = _t]),
#"Added Custom" = Table.AddColumn(Source, "money I want to come", (k)=> Table.SelectRows(#"Table 2",each [name]=k[name]){0}[money]/List.Count(List.Select(Source[name],each _=k[name])))
in
#"Added Custom"