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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How to count the number of active contracts per month when the months are the columns

Essentially, I have data like this:

Contracts

 

name,      work_type_id, start_date, end_date
contract1, 1,            1.1.2023,   31.5.2023
contract2, 2,            1.2.2023,   31.8.2023
contract3, 3,            1.4.2023,   31.5.2023
contract4, 2,            1.4.2023,   31.7.2023

 


Work types

 

name,         id, count_of_contracts
fix_plumbing, 1,  1
renovation,   2,  2
painting,     3,  1

 


These two tables are related by contracts.work_type_id and work_types.id.

I would like to have the data in this format:

 

name,        work_type, count_of_contracts_in_jan, count_of_contracts_in_feb, count_of_contracts_in_mar, count_of_contracts_in_apr, count_of_contracts_in_may, count_of_contracts_in_jun, count_of_contracts_in_jul, count_of_contracts_in_aug
fix_plumbing, 1,        1, 1, 1, 1, 1, 0, 0, 0
renovation,   2,        0, 1, 1, 2, 2, 2, 2, 1
painting,     3,        0, 0, 0, 1, 1, 0, 0, 0

 



In this output format, each month (from jan to dec) is a column, work types are rows, and the number of active contracts for each work type are the values. There are examples where the months are rows, but that is not sufficient in my case. 

 

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

2 REPLIES 2
Ahmedx
Super User
Super User

pls try this

Sample PBIX file attached
https://1drv.ms/u/s!AiUZ0Ws7G26Rh1kEh6qY-nXIMNGc?e=0r4ror
1.png2.png3.png

amitchandak
Super User
Super User

@Anonymous , Please refer to my HR current employee approach in Blog and attached file, I think that can help in this case

 

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

 

Usererlationship, inactive join, crossfilter to help

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.

Top Solution Authors