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.
Hello Everyone ,
Hope you are doing well.
I have a data 3 columns (Employee ID, Name , Date) .. I need a DAX formula which is like
1) present in Last Month
, 2) Present in Current_Month
3) Present in next month .
Please consider there is no termination date or other dates .
Regards,
Ramana PC
Solved! Go to Solution.
Thanks for the replies from FreemanZ and Kedar_Pande.
Hi @Raman3456 ,
Based on your description I created simple data:
Then create measures:
present in Last Month = CALCULATE(DISTINCTCOUNT('Table'[Employee ID]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),-2)+1&&'Table'[Date]<=EOMONTH(TODAY(),-1)))
Present in Current_Month = CALCULATE(DISTINCTCOUNT('Table'[Employee ID]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),-1)+1&&'Table'[Date]<=EOMONTH(TODAY(),0)))
Present in next month = CALCULATE(DISTINCTCOUNT('Table'[Employee ID]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),0)+1&&'Table'[Date]<=EOMONTH(TODAY(),1)))
HR Attrition Rate = DIVIDE([Present in Current_Month],[present in Last Month])
Forecast HR Attrition Rate = DIVIDE([Present in next month],[Present in Current_Month])
You can also use cards to display the names of absent employees, such as:
NextLostEmployee =
VAR _CurrentEmployee=CALCULATETABLE(VALUES('Table'[Name]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),-1)+1&&'Table'[Date]<=EOMONTH(TODAY(),0)))
VAR _NextEmployee=CALCULATETABLE(VALUES('Table'[Name]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),0)+1&&'Table'[Date]<=EOMONTH(TODAY(),1)))
VAR _LostEmployee=EXCEPT(_CurrentEmployee,_NextEmployee)
RETURN CONCATENATEX(_LostEmployee,'Table'[Name],"/")
Best Regards,
Zhu
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the replies from FreemanZ and Kedar_Pande.
Hi @Raman3456 ,
Based on your description I created simple data:
Then create measures:
present in Last Month = CALCULATE(DISTINCTCOUNT('Table'[Employee ID]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),-2)+1&&'Table'[Date]<=EOMONTH(TODAY(),-1)))
Present in Current_Month = CALCULATE(DISTINCTCOUNT('Table'[Employee ID]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),-1)+1&&'Table'[Date]<=EOMONTH(TODAY(),0)))
Present in next month = CALCULATE(DISTINCTCOUNT('Table'[Employee ID]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),0)+1&&'Table'[Date]<=EOMONTH(TODAY(),1)))
HR Attrition Rate = DIVIDE([Present in Current_Month],[present in Last Month])
Forecast HR Attrition Rate = DIVIDE([Present in next month],[Present in Current_Month])
You can also use cards to display the names of absent employees, such as:
NextLostEmployee =
VAR _CurrentEmployee=CALCULATETABLE(VALUES('Table'[Name]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),-1)+1&&'Table'[Date]<=EOMONTH(TODAY(),0)))
VAR _NextEmployee=CALCULATETABLE(VALUES('Table'[Name]),FILTER('Table','Table'[Date]>=EOMONTH(TODAY(),0)+1&&'Table'[Date]<=EOMONTH(TODAY(),1)))
VAR _LostEmployee=EXCEPT(_CurrentEmployee,_NextEmployee)
RETURN CONCATENATEX(_LostEmployee,'Table'[Name],"/")
Best Regards,
Zhu
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Here my fields are
Employee ID , Name , Date
I need the solution like
If any employee which will not be available in next month consider it as attrition .
So .... I need a proper dax (to find present, past and next ) based on employee ID .
You can create measures for each condition based on the Date column
Present_LastMonth =
VAR LastMonthStart = DATE(YEAR(TODAY()), MONTH(TODAY()) - 1, 1)
VAR LastMonthEnd = EOMONTH(LastMonthStart, 0)
RETURN
IF(
CALCULATE(COUNTROWS('Table'), 'Table'[Date] >= LastMonthStart, 'Table'[Date] <= LastMonthEnd) > 0,
1,
0
)
Present_CurrentMonth =
VAR CurrentMonthStart = DATE(YEAR(TODAY()), MONTH(TODAY()), 1)
VAR CurrentMonthEnd = EOMONTH(CurrentMonthStart, 0)
RETURN
IF(
CALCULATE(COUNTROWS('Table'), 'Table'[Date] >= CurrentMonthStart, 'Table'[Date] <= CurrentMonthEnd) > 0,
1,
0
)
Present_NextMonth =
VAR NextMonthStart = EOMONTH(TODAY(), 0) + 1
VAR NextMonthEnd = EOMONTH(TODAY(), 1)
RETURN
IF(
CALCULATE(COUNTROWS('Table'), 'Table'[Date] >= NextMonthStart, 'Table'[Date] <= NextMonthEnd) > 0,
1,
0
)
You can add these measures to your report to evaluate the presence of employees for the specified time frames.
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Hi @Raman3456 ,
try like:
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 |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |