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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.