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
lotus22
Helper III
Helper III

Combine Rows in PowerQuery

I could use GroupBy but I only want to Combine data with column that has particular value? I want to only combine rows with value B. Off course there are other columns as well.

 

Value A

Value A

Value B

Value B

Value B

Value B

Value C

Value C

Value C

1 ACCEPTED SOLUTION
bcdobbs
Super User
Super User

Could you:

 

Make 2 reference copies of the initial query.

 

Filter 1 to just include B rows and the other to not include B rows.

 

Apply group by to the query with just B rows.

 

Append the queries back together.

 

Mark all the helper stages as do not load.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

3 REPLIES 3
mahoneypat
Employee
Employee

Here's one way to do it in the query editor.  To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkvMKU1VcFSK1YlWAhM4BJyoIOBMjEAsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", type text}}),
    Split = Table.SelectRows(#"Changed Type", each ([Value] <> "")),
    #"Filtered Rows" = Table.SelectRows(Split, each ([Value] = "Value B")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Value"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
    Custom1 = Split,
    #"Filtered Rows1" = Table.SelectRows(Custom1, each ([Value] <> "Value B")),
    #"Appended Query" = Table.Combine({#"Filtered Rows1", #"Grouped Rows"})
in
    #"Appended Query"

 

mahoneypat_0-1639693299895.png

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


bcdobbs
Super User
Super User

Could you:

 

Make 2 reference copies of the initial query.

 

Filter 1 to just include B rows and the other to not include B rows.

 

Apply group by to the query with just B rows.

 

Append the queries back together.

 

Mark all the helper stages as do not load.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Great clever IDEA!! thank you!!

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.