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
oscarr29
Helper I
Helper I

how to use power bi Group same name with different detail and sum total

Hi all

anyone know how to use power bi Group same name with different detail and sum total?

pls refer to Pic

Thanks

Example.png

2 ACCEPTED SOLUTIONS

Hi @oscarr29

 

I've uploaded a pbix file here.

 

I just created a table matching your example, just called it Dataimage.png

 Create [detail concatenated] measure

image.png

 Drag elements into a tableimage.png

 

You may want to suppress the totals for [detail concatenated] - would require a tweak.

 

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

Hi @oscarr29,

 

Below are some detail operation steps and comment.

 

First, group data by "Group by" function.

5.gif

 

Comment:

Column 'Detail', 'Deposit' and 'Sell' need to be summarized. For 'Deposit' and 'Sell' can simply use existed 'sum' option to get summary value.

Current power query not contains exists function to directly transform 'detail' column, so I store all group records data as contents. (we need to modify function formula to convert data)

 

Since you only need to expand detail column items to one cell, so I use ['Column Name'] to get grouped 'Detail' column item list.

= Table.Group(#"Changed Type", {"Name"}, {{"Detail", each _[Detail], type table}, {"Deposit", each List.Sum([Deposit]), type number}, {"Sell", each List.Sum([Sell]), type number}})

Then, we need to consider to combine items to one, I found power query contains 'Text.Combine' function can used to combine list items to one with specific separator.


I modify query to use 'Text.Combine' to return combined result.

= Table.Group(#"Changed Type", {"Name"}, {{"Detail", each Text.Combine(_[Detail],"*"), type table}, {"Deposit", each List.Sum([Deposit]), type number}, {"Sell", each List.Sum([Sell]), type number}})

6.gif

 

Reference link:

Power Query Operators

Text.Combine

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

8 REPLIES 8
OwenAuger
Super User
Super User

Hi @oscarr29

 

If you just want to create a table visual with conatenated detail column (leaving underlying data unchanged), you can create a measure like this:

 

detail concatenated =
CONCATENATEX ( VALUES ( YourTable[detail] ), YourTable[detail], "*" )

Then add it as a value field in a table along with Name/deposit/sell.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi @OwenAuger

thanks for replay.

can you pls make a sample pic, how to create ?

Thanks

Hi @oscarr29

 

I've uploaded a pbix file here.

 

I just created a table matching your example, just called it Dataimage.png

 Create [detail concatenated] measure

image.png

 Drag elements into a tableimage.png

 

You may want to suppress the totals for [detail concatenated] - would require a tweak.

 

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Hi @OwenAuger

 

If at Queries there, how to make it?

 

Q.png

Hi @oscarr29,

 

You can use power query group function to achieve your requirement:

10.PNG

 

Full query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wyk7NU9JRSk4sApKGBiCAYMTqwOQz8kuLU4G0EUyFMbqKgoz8vFSoVqhCJNmcxIKS/AKYuI6SKUy6sjQ7E26/qQFCM6o8zH5jqAozDBUw+40Q7gNLl2TmovoP1XyINIrxIBUWUBWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Detail = _t, Deposit = _t, Sell = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Detail", type text}, {"Deposit", Int64.Type}, {"Sell", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, {{"Detail", each Text.Combine(_[Detail], "*"), type text},{"Deposit", each List.Sum([Deposit]), type number}, {"Sell", each List.Sum([Sell]), type number}})
in
    #"Grouped Rows"

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft

you give that solution is solve, but can you screenshot your step to me? because i want to learn how to build it

Thanks

Hi @oscarr29,

 

Below are some detail operation steps and comment.

 

First, group data by "Group by" function.

5.gif

 

Comment:

Column 'Detail', 'Deposit' and 'Sell' need to be summarized. For 'Deposit' and 'Sell' can simply use existed 'sum' option to get summary value.

Current power query not contains exists function to directly transform 'detail' column, so I store all group records data as contents. (we need to modify function formula to convert data)

 

Since you only need to expand detail column items to one cell, so I use ['Column Name'] to get grouped 'Detail' column item list.

= Table.Group(#"Changed Type", {"Name"}, {{"Detail", each _[Detail], type table}, {"Deposit", each List.Sum([Deposit]), type number}, {"Sell", each List.Sum([Sell]), type number}})

Then, we need to consider to combine items to one, I found power query contains 'Text.Combine' function can used to combine list items to one with specific separator.


I modify query to use 'Text.Combine' to return combined result.

= Table.Group(#"Changed Type", {"Name"}, {{"Detail", each Text.Combine(_[Detail],"*"), type table}, {"Deposit", each List.Sum([Deposit]), type number}, {"Sell", each List.Sum([Sell]), type number}})

6.gif

 

Reference link:

Power Query Operators

Text.Combine

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft

thanks for your help and detail operation steps..

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.