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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
heriberto_mb
Frequent Visitor

How to show the rows with more data in PowerQuery/PowerBI?

I'm struggling how to identify the rows that have more data based on a column, in this case: Owner, if there is no Owner at all, show the row with no owner. PowerQuery is preferable, but if that is not possible, using PowerBI

 

Example:

ColorStateToyOwner
BlueMIcar 
BlueMItrainSnoopy
YellowAZballCharlie
YellowAZyoyo 
RedCOdoll 
RedCOdoll 

 

Desired resultNo matter what Toy is it, report only the row which has an owner if it exists.

ColorStateToyOwner
BlueMItrainSnoopy
YellowAZballCharlie
RedCOdoll 
1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @heriberto_mb,

The most straight forward method is through a Group By on Color and State.

m_dekorte_0-1725398930429.png

 

Give this a go.

let
    Source = Table.FromRows(
        {  
            {"Blue", "MI", "car", null},
            {"Blue", "MI", "train", "Snoopy"},
            {"Yellow", "AZ", "ball", "Charlie"},
            {"Yellow", "AZ", "yoyo", null},
            {"Red", "CO", "doll", null},
            {"Red", "CO", "doll", null}
        }, type table [Color=text, State=text, Toy=text, Owner=text]
    ),
    GroupRows = Table.Combine( 
        Table.Group( Source, {"Color", "State"}, {
            {"data", each Table.FirstN( Table.Sort(_, {"Owner", 1}), 1), 
            type table [Color=text, State=text, Toy=text, Owner=text]}
        })[data]
    )
in
    GroupRows

I hope this is helpful

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @heriberto_mb, do not double-post please.

 

Solution also here.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

m_dekorte
Super User
Super User

Hi @heriberto_mb,

The most straight forward method is through a Group By on Color and State.

m_dekorte_0-1725398930429.png

 

Give this a go.

let
    Source = Table.FromRows(
        {  
            {"Blue", "MI", "car", null},
            {"Blue", "MI", "train", "Snoopy"},
            {"Yellow", "AZ", "ball", "Charlie"},
            {"Yellow", "AZ", "yoyo", null},
            {"Red", "CO", "doll", null},
            {"Red", "CO", "doll", null}
        }, type table [Color=text, State=text, Toy=text, Owner=text]
    ),
    GroupRows = Table.Combine( 
        Table.Group( Source, {"Color", "State"}, {
            {"data", each Table.FirstN( Table.Sort(_, {"Owner", 1}), 1), 
            type table [Color=text, State=text, Toy=text, Owner=text]}
        })[data]
    )
in
    GroupRows

I hope this is helpful

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.