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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
CBO2404
Helper I
Helper I

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
Helper I
Helper I

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
Helper I
Helper I

This is my solution after trying again and again:

 

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

 

thanks for the suggested solution

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.