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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Count of a particular column based on another column of the different table

Hi,

 

I am new to Power BI and will appreciate any help with my question.

 

I have a table named 'Datetime' with hour data as shown below:

 

Diptanshulal_1-1672223071261.png

 

I have another table 'Info_table' with student information as shown below:

 

Diptanshulal_2-1672223126513.png

 

I want to add a new column in the 'Datetime' table which will count the arrivals of students in each hour period as shown below:

 

Diptanshulal_3-1672223197352.png

Here, 'Arrivals count' is 2 for '1/1/2020 21:00' because student ids 234 and 789 arrived between 21:00 - 22:00 hr as can be seen in the 'Info_table'.

 

Please let me know how this can be achieved.

 

Thanks!!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Start with no relationship between the tables. Add a calculated column like:

Arrivals count column = 
  VAR __StartTime = 'Datetime'[Datetime]
  VAR __EndTime = __StartTime + 1/24
  VAR __Table = FILTER('Info_table', [Arrival] >= __StartTime && [Arrival] <= __EndTime)
  VAR __Result = COUNTROWS(__Table)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Anonymous Start with no relationship between the tables. Add a calculated column like:

Arrivals count column = 
  VAR __StartTime = 'Datetime'[Datetime]
  VAR __EndTime = __StartTime + 1/24
  VAR __Table = FILTER('Info_table', [Arrival] >= __StartTime && [Arrival] <= __EndTime)
  VAR __Result = COUNTROWS(__Table)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you @Greg_Deckler !! This works perfect.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors
Top Kudoed Authors