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
nikhil0511
Advocate I
Advocate I

Adding rows in power Pivot for Excel -datamodel

Hello Forum,

 

I need an assistance in adding up two or multiple values for my calculation in datamodel. Please find the below sample data and output I expect.

 

ParentChildInfo
A122
A245

 

now I want to sum the info values as per the Parent and remove the duplicate parent values. so that I get unique values at the end.

 

Please note I am doing this in Data model -PowerPivot for Excel.

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @nikhil0511 ,

Is this your expected result?

vkalyjmsft_0-1667555808816.png

If so, I can do it in Power Query. Please copy-paste the below code in a blank query to see the details.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYiMjpVgdCNcIiE1MlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parent = _t, Child = _t, Info = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}, {"Child", Int64.Type}, {"Info", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Parent"}, {{"Child", each null, type nullable number},{"Info", each List.Sum([Info]), type nullable number} }),
    #"Appended Query" = Table.Combine({#"Changed Type", #"Grouped Rows"})
in
    #"Appended Query"

 

I also attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @nikhil0511 ,

Is this your expected result?

vkalyjmsft_0-1667555808816.png

If so, I can do it in Power Query. Please copy-paste the below code in a blank query to see the details.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYiMjpVgdCNcIiE1MlWJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Parent = _t, Child = _t, Info = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Parent", type text}, {"Child", Int64.Type}, {"Info", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Parent"}, {{"Child", each null, type nullable number},{"Info", each List.Sum([Info]), type nullable number} }),
    #"Appended Query" = Table.Combine({#"Changed Type", #"Grouped Rows"})
in
    #"Appended Query"

 

I also attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yanjiang-msft,

 

Thanks for the response. 

I was able to perform the following output in Power Query using GroupBy and Sum. but i was expecting this to be done in Excel Data Model, as the Info column I provided in example is a calculated column in DataModel and needs to provide me the result in DataModel.

 

Regards

Nikhil

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