Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
DAXI have a month wise employee data (sample below) and I want to calculate the leavers (removed) and joiners(added) by month.
e.g. Jan 2016, I want to know many entries removed and how many new entries added vs dec 2015, feb 2016 vs jan 2016 and so on in a single query.
Any help would be appreciated.
Regards,
Year | Month | Branch | Emp Name | Emp No |
2015 | 12 | B1 | Emp1 | 1 |
2015 | 12 | B2 | Emp2 | 2 |
2015 | 12 | B1 | Emp3 | 3 |
2015 | 12 | B2 | Emp4 | 4 |
2015 | 12 | B1 | Emp5 | 5 |
2015 | 12 | B1 | Emp6 | 6 |
2016 | 1 | B1 | Emp1 | 1 |
2016 | 1 | B2 | Emp2 | 2 |
2016 | 1 | B1 | Emp3 | 3 |
2016 | 1 | B2 | Emp4 | 4 |
2016 | 1 | B1 | Emp7 | 7 |
2016 | 1 | B1 | Emp6 | 6 |
2016 | 1 | B2 | Emp8 | 8 |
2016 | 2 | B1 | Emp1 | 1 |
2016 | 2 | B2 | Emp2 | 2 |
2016 | 2 | B1 | Emp3 | 3 |
2016 | 2 | B1 | Emp7 | 7 |
2016 | 2 | B1 | Emp6 | 6 |
2016 | 2 | B2 | Emp8 | 8 |
2016 | 2 | B1 | Emp9 | 9 |
2016 | 2 | B2 | Emp10 | 10 |
2016 | 2 | B1 | Emp11 | 11 |
2016 | 2 | B2 | Emp12 | 12 |
2016 | 3 | B1 | Emp1 | 1 |
2016 | 3 | B2 | Emp2 | 2 |
2016 | 3 | B1 | Emp3 | 3 |
2016 | 3 | B1 | Emp7 | 7 |
2016 | 3 | B2 | Emp10 | 10 |
2016 | 3 | B1 | Emp11 | 11 |
2016 | 3 | B2 | Emp12 | 12 |
2016 | 3 | B2 | Emp13 | 13 |
2016 | 3 | B2 | Emp14 | 14 |
2016 | 4 | B1 | Emp1 | 1 |
2016 | 4 | B2 | Emp2 | 2 |
2016 | 4 | B1 | Emp3 | 3 |
2016 | 4 | B1 | Emp7 | 7 |
2016 | 4 | B2 | Emp10 | 10 |
2016 | 4 | B2 | Emp14 | 14 |
Solved! Go to Solution.
In my opinion, you will need some calculcated columns, a calendar table and some measures in this case.
calculated columns
Date = DATE(Entries[Year],Entries[Month],1)
if last month's entry exists =
SWITCH (
TRUE (),
CALCULATE (
VALUES ( Entries[Emp No] ),
FILTER (
ALL ( Entries ),
EARLIER ( Entries[Branch] ) = Entries[Branch]
&& EARLIER ( Entries[Emp No] ) = Entries[Emp No]
&& EARLIER ( Entries[Date] ) = DATEADD ( Entries[Date], +1, MONTH )
)
)
= BLANK (), "N",
"Y"
)
Measures
new entries = CALCULATE(COUNTROWS(Entries),Entries[if last month's entry exists]="N") removed entires = COUNTROWS ( FILTER ( ALL ( Entries ), MAX ( 'Calendar'[Date] ) = DATEADD ( Entries[Date], +1, MONTH ) ) ) // last month's entries - ( COUNTROWS ( Entries ) - [new entries] )
Check more details in the attached pbix.
In my opinion, you will need some calculcated columns, a calendar table and some measures in this case.
calculated columns
Date = DATE(Entries[Year],Entries[Month],1)
if last month's entry exists =
SWITCH (
TRUE (),
CALCULATE (
VALUES ( Entries[Emp No] ),
FILTER (
ALL ( Entries ),
EARLIER ( Entries[Branch] ) = Entries[Branch]
&& EARLIER ( Entries[Emp No] ) = Entries[Emp No]
&& EARLIER ( Entries[Date] ) = DATEADD ( Entries[Date], +1, MONTH )
)
)
= BLANK (), "N",
"Y"
)
Measures
new entries = CALCULATE(COUNTROWS(Entries),Entries[if last month's entry exists]="N") removed entires = COUNTROWS ( FILTER ( ALL ( Entries ), MAX ( 'Calendar'[Date] ) = DATEADD ( Entries[Date], +1, MONTH ) ) ) // last month's entries - ( COUNTROWS ( Entries ) - [new entries] )
Check more details in the attached pbix.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
73 | |
58 | |
35 | |
31 |
User | Count |
---|---|
99 | |
57 | |
56 | |
46 | |
40 |