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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Rince91
Helper I
Helper I

Count matching column values based on visual selection

Hi All,

 

I have a bar chart showing the monthly payroll, Im trying to create another visual that will provide the number of people that have started in the month i have selected on that bar chart. Below is some example data.

 

For example if i select January Payroll date on the bar chart visual, I would like it to return 4.

 

Start DatePayroll DatePay
01 January 202328 January 2023£100.00
01 January 202328 February 2023£150.00
01 January 202328 March 2023£75.00
01 February 202328 February 2023£50.00
01 February 202328 March 2023£100.00
01 March 202328 April 2023£200.00
01 March 202328 March 2023£300.00
01 January 202328 February 2023£400.00
01 February 202328 March 2023£500.00
01 February 202328 March 2023£600.00

 

I have tried this measure but can't get it to work.

 

Joiners =

VAR selectedDate = SELECTEDVALUE('Table'[Payroll Date].[Month])

RETURN
CALCULATE(
    COUNT('Table'[Start Date]),FILTER('Table','Table'[Start Date].[Month] = selecteddate))
1 ACCEPTED SOLUTION
OguzMavice
Resolver II
Resolver II

Hi @Rince91 ,

 

I think so that your master date table has relationship with Payroll Date of your Payroll Table. In this type situation, you can use "Userrelationship"  function in order to show  result based on your second date column. 

 

First of all, you should create relationship between secondary date column and master date table.

OguzMavice_0-1700072633265.png

Then use this measure ;

 

# People = CALCULATE(COUNT('Table'[Start Date]),USERELATIONSHIP('Date'[Date],'Table'[Start Date]))
 
the result  ;
 
OguzMavice_1-1700072690767.png

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
OguzMavice
Resolver II
Resolver II

Hi @Rince91 ,

 

I think so that your master date table has relationship with Payroll Date of your Payroll Table. In this type situation, you can use "Userrelationship"  function in order to show  result based on your second date column. 

 

First of all, you should create relationship between secondary date column and master date table.

OguzMavice_0-1700072633265.png

Then use this measure ;

 

# People = CALCULATE(COUNT('Table'[Start Date]),USERELATIONSHIP('Date'[Date],'Table'[Start Date]))
 
the result  ;
 
OguzMavice_1-1700072690767.png

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Great thanks this worked!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors