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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
rinaemo
Frequent Visitor

Count of Rows using Master Calendar

Hi Experts,

 

I was told to create a master calendar to count the number of employees for the start and end date by Month and Year. I am very new to PowerBI and i have no idea how to start with and how to proceed with the data.

 

Over here i have 4 columns in my current table:

1. Employee ID

2. Employee Name

3. Join Date

4. End Date

 

I need to create a visualization of Month and Year of how many employees is present in the company...

 

Can anyone advise on how do i create this? Much appreciated! Thanks!

1 ACCEPTED SOLUTION

Hi , @rinaemo 

Thanks for yoour quick response ! 

According to your description, you just want to calculate the number of people who are on the job in the middle of the year and month, and for your needs, I have implemented it in the above example, and it is according to your logic to calculate.

 

If you want to filter based on the year and month you choose, you just need to put [Date] in 'Calendar' in slicer, and then you can implement your needs,like this:

vyueyunzhmsft_0-1670564924516.png

 

If this method does not meet your needs, you can provide us with  the desired output sample screenshot, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

7 REPLIES 7
v-yueyunzh-msft
Community Support
Community Support

Hi , @rinaemo 

According to your description, you want to "create a visualization of Month and Year of how many employees is present in the company.". Right?

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1670467402375.png

(2)We can create a master date you need , we can click "New Table" and enter this:

Calendar = ADDCOLUMNS( 
CALENDAR(FIRSTDATE('Table'[Join Date]),TODAY()),
"year", YEAR ( [Date] ),
"month", MONTH([Date])
)

And we do not need to make relationship between two tables.

 

(3)In the fact table , we need to click "New Column" to create a calculated column to show the end [End Date] if the [End Date] is BLANK() then we retun the TODAY() date:

End Date result = IF([End Date] = BLANK() , TODAY() , [End Date])

 

(4)Then we can create a measure like this:

Measure = var _cur_year_month = MAX('Calendar'[year_month])
var _t = FILTER( 'Table' , _cur_year_month >= YEAR('Table'[Join Date])*100+MONTH('Table'[Join Date])  && _cur_year_month<=YEAR('Table'[End Date result])*100+MONTH('Table'[End Date result]))
return
COUNTROWS(_t)

(5)Then we put the fields we need on the visual and we can meet your need:

vyueyunzhmsft_1-1670468185426.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Hi Aniya,

 

My end date is from the initial table, how do i do the following to link to my other table? 

 

End Date result = IF([End Date] = BLANK() , TODAY() , [End Date])

 

On top of that, the requirement just changed to only calculating dates that are of 1st of the month and year. I need to take in consideration of the start date and end date on every 1st of the month to keep track of the number of employees in the company. 

Hi, @rinaemo 

Hello, if your end date is from another table, then you can establish a relationship for the two tables, and then get the corresponding end date.

For your following needs, if you can, I hope you can provide us with sample data of all your tables, as well as your relationship, and give us the final result you want in the form of a table according to the sample data, so that we can better help you.

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Hi Aniya,

 

My raw data looks like this:

Employee No:Name:Employment Type:Join DateEnd Date
1235250AlbertContractor1 Jan 20229 Dec 2022
3930434JennyPerm5 May 2010 
2532403MarlinaPerm10 May 2022 
2402402CharlotteContract1 Mar 20005 Nov 2010
2402440TristanPerm3 May 20053 May 2022

 

I am looking to see a chart visualization with card filter to allow me to select the Month and Year with the data showing the number of employees in the company as of 1st of every month. So lets say for May 2022, given that Jenny, Marlina and Tristan are still working in the company, i should get the count of 3 Employees working in the company, with all 3 of them being the Perm staff. 

 

My superior told me to use a master calendar to manage the dates as this data will be for long-run to capture the monthly data of the number of employees all the way from 2000 and go on from there.

Hi , @rinaemo 

Thanks for yoour quick response ! 

According to your description, you just want to calculate the number of people who are on the job in the middle of the year and month, and for your needs, I have implemented it in the above example, and it is according to your logic to calculate.

 

If you want to filter based on the year and month you choose, you just need to put [Date] in 'Calendar' in slicer, and then you can implement your needs,like this:

vyueyunzhmsft_0-1670564924516.png

 

If this method does not meet your needs, you can provide us with  the desired output sample screenshot, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

Ohh ya, fyi the data for my PowerBI is pulled directly from a live SQL database.

ryan_mayu
Super User
Super User

@rinaemo 

pls see the attachment below. hope this is helpful





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

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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