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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
E_hit
Frequent Visitor

countrows based on slicer & related table

Hi,

 

I've got 2 tables

- one with my list of clients

- another with list of apointments related to clients with a date

 

I want to set a date slicer in excel to get the number of apointments per clients at a given date / date range

 

I have created a measure :

Date_selected:=max(tbmkg_apointment[Date_apointment])

 

and a calculated column in my client table but I either go the total number of apointment non related to distinct client with this formula

CALCULATE(
COUNTROWS(tbmkg_apointment);
FILTER (tbmkg_apointment;
tbmkg_apointment[Date_apointment]>= tbmkg_apointment[Date_selected] ) )

or a results taht take into account all apointments for one client even if only one of them is at the desired date:

CALCULATE(
COUNTROWS(RELATEDTABLE(tbmkg_apointment));
FILTER (RELATEDTABLE(tbmkg_apointment);
tbmkg_apointment[Date_apointment]>= tbmkg_apointment[Date_selected] ) )

 

Any insights?

 

Below is a data sample:

table client

code_clientnb_apointmentclient_age
4641231254 123
4641231255 136

 

table apointment

code_apointmentdate_apointmenttype_apointmentcode_client
32323/05/2018A4641231254
56524/05/2018B4641231255

 

I want my calculate field in my client table in nb_apointment

 

Thanks!

 

2 REPLIES 2
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @E_hit,

Based on my test, you could refer to this formula:

nb_apointment = CALCULATE(
COUNT(apointment[code_apointment]),
FILTER (apointment,
apointment[Date_apointment]>= MAX('apointment'[date_apointment]) ))

Result:

1.PNG

 

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/sx88kxa0sraht5g/countrows%20based%20on%20slicer%20%26%20related%20table.pb...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hey,

 

Thanks for the answer. However it doesn't work as expected on my file (I am using power pivot for excel so I cannot check your power BI file)

The results I have in my column is the total number of appointment, whatever the user. Instead I would like the number of apointment per user

 

With data sample:

table apointment 

code_apointmentdate_apointmenttype_apointmentcode_client
32323/05/2018A1234
56524/05/2018B6523
54620/02/2018C8965
13508/09/2017C8965

 

the results I get on my client table

code_clientnb_apointmentclient_age
1234423
6523436
8965456

 

The results I want on my client table:

code_clientnb_apointmentclient_age
1234123
6523136
8965256

 

The tables are linked with the code_client

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.