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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
MightyRabbit
Frequent Visitor

Count the missing Number

Hi everyone, 

I need help with query and hope you guys can help. I have a table like this:

NumberCodeIO
123A1
123B 
456A1
456B 
789A1
911A1


If number has code A & the IO = 1, so they should have the same number with Code B in the table.
My question is how could I figure out, the total number of missing code B, when the have IO = 1. 
In this case, the result should be 2 (789 and 911).

Thank you very much. 


1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

Hi, @MightyRabbit 

let
    Source = your_table,
    code_io = Table.AddColumn(Source, "code_io", each Text.Combine({[Code], Text.From([IO])}, ""), type text),
    gr = Table.Group(code_io, "Number", {{"all", each _}}),
    select = Table.SelectRows(gr, each List.Contains([all][code_io], "A1") and not List.Contains([all][Code], "B")),
    out = Table.RowCount(select)
in
    out

View solution in original post

4 REPLIES 4
MightyRabbit
Frequent Visitor

Hi @AlienSx , 

appreciate your help. 

MightyRabbit
Frequent Visitor

@AlienSx ; Thank you so much 🙂
Just one more thing, how could I Filter out these number in a table, that means I want to have a table with Code A, IO = 1, but missing B. 

789A1
911A1

let
    Source = your_table,
    code_io = Table.AddColumn(Source, "code_io", each Text.Combine({[Code], Text.From([IO])}, ""), type text),
    gr = Table.Group(code_io, "Number", {{"all", each _}}),
    select = Table.SelectRows(gr, each List.Contains([all][code_io], "A1") and not List.Contains([all][Code], "B")),
    expand = Table.ExpandTableColumn(select, "all", {"Code", "IO"})
in
    expand
AlienSx
Super User
Super User

Hi, @MightyRabbit 

let
    Source = your_table,
    code_io = Table.AddColumn(Source, "code_io", each Text.Combine({[Code], Text.From([IO])}, ""), type text),
    gr = Table.Group(code_io, "Number", {{"all", each _}}),
    select = Table.SelectRows(gr, each List.Contains([all][code_io], "A1") and not List.Contains([all][Code], "B")),
    out = Table.RowCount(select)
in
    out

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors