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

How to count number of non-null record from another table

Hello,

 

I have two tables,  table A and Tablt B, join by truck number, it is a one to many relationship

 

 A:

Truck Number # Checks# Dispatch
100112

B:

Truck NumberChekin TimeDispach Time
10011:309:00
1001 9:00

 

 

Idally, it will give the 2 in diaptach column in table A(even if the record in table B, it is the same tim), and give me 1 times for chckin in time, because there is null record in table B. curretly i am using the following formula, but it gives both for 2. does anyone know I can I make it not count this blank record, and still count 2 for even I have the same dispatch time.

 

DISPATCHS = IF(ISBLANK( COUNT(DISPATCH[DISPATCH_TIME])),0,COUNT(DISPATCH[DISPATCH_TIME]))

 

Thanks

Frank

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @NoobAnalyst01,

 

How are you setting up the visuals? I have made a mockup of your information and just by choosing count on the dispatch and check in it gives me 2 and 1.

 

count.gif

 

Not really sure what you want to achieve, can you please ellaborate better and give a more extendend sample data and expected result.

 

Normally blanks or null aren't consider in the count and sum.

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @NoobAnalyst01,

 

In TableA, please create below calculated columns:

# Checks =
CALCULATE (
    COUNTROWS ( FILTER ( TableB, TableB[Chekin Time] <> BLANK () ) ),
    USERELATIONSHIP ( TableA[Truck Number], TableB[Truck Number] )
)

# Dispatch =
CALCULATE (
    COUNT ( TableB[Dispach Time] ),
    ALLEXCEPT ( TableA, TableA[Truck Number] )
)

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @NoobAnalyst01,

 

How are you setting up the visuals? I have made a mockup of your information and just by choosing count on the dispatch and check in it gives me 2 and 1.

 

count.gif

 

Not really sure what you want to achieve, can you please ellaborate better and give a more extendend sample data and expected result.

 

Normally blanks or null aren't consider in the count and sum.

 

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.