cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CBO2404
Frequent Visitor

Employees in the next month and which employees are new or left (also on employee detail level)

What I want to see in the 2nd column of my matrix visual: how many employees are there in the next month and later on which employees are new or let.

I want to do this by comparing the population of employees (this month vs next month) because I want to make this visual by department. Some employees change department and I want to see who is new/left in the department.

 

The first step I try is to count the rows of the next month but I get a blank result. (see example below: When you click on the month you see the employees in detail)

CBO2404_0-1634804180869.png 

CBO2404_1-1634804639791.png

 

You can see the used measure below. When I use the thismonth value to return , return COUNTROWS(distinct(EmployeesOnFirstDateThisMonth)),  I get the same value as in the 1st column so that works fine.

I have used an all filter but that doesn't work.

 

So what am I doing wrong?

 

My measure:

EmployeesNextMonth =

      VAR Firstdaythismonth = FIRSTDATE('MyOwndatetable'[date])
      VAR Firstdaynextmonth = FIRSTDATE(NEXTMONTH('MyOwndatetable'[date]))

 

      VAR EmployeesOnFirstDateThisMonth =
          CALCULATETABLE(VALUES('EmployeeTable'[Employee]),
             FILTER(VALUES('EmployeeTable'[date]),'EmployeeTable'[date] = Firstdaythismonth)
          )

      VAR EmployeesOnFirstDateNextMonth =
          CALCULATETABLE(VALUES('EmployeeTable'[Employee]),
             FILTER(VALUES('EmployeeTable'[date]),'EmployeeTable'[date] = Firstdaynextmonth)
      )

return COUNTROWS(distinct(EmployeesOnFirstDateNextMonth))


--return COUNTROWS(distinct(EmployeesOnFirstDateThisMonth)) THIS RETURNS THE CORRECT VALUE

1 ACCEPTED SOLUTION
CBO2404
Frequent Visitor

This is my solution after trying again and again:

 

CALCULATETABLE(VALUES('EmployeeTable'[Employee]),
DATESBETWEEN('MyOwndatetable'[date],Firstdaynextmonth,Firstdaynextmonth)

 

thanks for the suggested solution

View solution in original post

2 REPLIES 2
CBO2404
Frequent Visitor

This is my solution after trying again and again:

 

CALCULATETABLE(VALUES('EmployeeTable'[Employee]),
DATESBETWEEN('MyOwndatetable'[date],Firstdaynextmonth,Firstdaynextmonth)

 

thanks for the suggested solution

View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @CBO2404 ,

I created some data:

vyangliumsft_0-1635136053770.png

Here are the steps you can follow:

1. Create calculated column.

YEAR_MONTH = YEAR('Table'[date])&""&MONTH('Table'[date])
Index = RANKX('Table',[date],,ASC,Dense)
Status =
var _lastdeport=CALCULATE(MAX('Table'[deport]),FILTER('Table',[ID]=EARLIER('Table'[ID])&&[Index]=EARLIER('Table'[Index])-1))
return
IF(
    [deport]<>_lastdeport,IF([Index]=1,"Old","New"),"Old")

vyangliumsft_1-1635136053780.png

2. Create measure.

Flag =
IF(
    ISINSCOPE('Table'[ID]),
MIN('Table'[Status]),CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[YEAR_MONTH]=MAX('Table'[YEAR_MONTH]))))

3. Result:

vyangliumsft_2-1635136053782.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors