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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
benz-fsproduce
Frequent Visitor

retention rate

Hi I am trying to calulate retention rate year by year. 

My current measure is:

benzfsproduce_0-1658408164353.pngbenzfsproduce_1-1658408258421.png

 

 

 
 
It gives me retention rate, but it won't calculate for the current year. It works for previous years, but it will not for 2022. I know that it has something to do with the IF function. I would really appreciate some help. Thanks.
1 ACCEPTED SOLUTION

@benz-fsproduce , I want you remove the if condition, as max of 2022 is > today 

 

Retention Rate 2 =
VAR _StartOfPeriod = MIN('Date'[Date])
VAR _EndOfPeriod = MAX('Date'[Date])
VAR _Result =
IF( 1=1,
VAR _EmployeesAtStart =
CALCULATETABLE(
VALUES(page[Employee Name]),
page[Last Hire Date] <= _StartOfPeriod,
page[Termination Date] >= _StartOfPeriod || ISBLANK(page[Termination Date])
)
VAR _EmployeesAtEnd =
CALCULATETABLE(
VALUES(page[Employee Name]),
page[Last Hire Date] <= _EndOfPeriod,
page[Termination Date] >= _EndOfPeriod || ISBLANK(page[Termination Date])
)
VAR _NoOFEmployeesAtStartAndEnd =
COUNTROWS(
INTERSECT(_EmployeesAtStart, _EmployeesAtEnd)
)
RETURN
DIVIDE(_NoOFEmployeesAtStartAndEnd, COUNTROWS(_EmployeesAtStart))
)
RETURN
_Result

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@benz-fsproduce , remove the condition on today and try.

 

if not share formula in text format

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I tried removing "IF( TODAY() >= _EndOfPeriod," but it ended with an error. Here is my formula in text form.
 
Retention Rate 2 =
VAR _StartOfPeriod = MIN('Date'[Date])
VAR _EndOfPeriod = MAX('Date'[Date])
VAR _Result =
IF( TODAY() >= _EndOfPeriod,
    VAR _EmployeesAtStart =
    CALCULATETABLE(
        VALUES(page[Employee Name]),
        page[Last Hire Date] <= _StartOfPeriod,
        page[Termination Date] >= _StartOfPeriod || ISBLANK(page[Termination Date])
    )
    VAR _EmployeesAtEnd =
    CALCULATETABLE(
        VALUES(page[Employee Name]),
        page[Last Hire Date] <= _EndOfPeriod,
        page[Termination Date] >= _EndOfPeriod || ISBLANK(page[Termination Date])
    )
    VAR _NoOFEmployeesAtStartAndEnd =
    COUNTROWS(
        INTERSECT(_EmployeesAtStart, _EmployeesAtEnd)
    )
    RETURN
        DIVIDE(_NoOFEmployeesAtStartAndEnd, COUNTROWS(_EmployeesAtStart))
)
RETURN
    _Result

@benz-fsproduce , I want you remove the if condition, as max of 2022 is > today 

 

Retention Rate 2 =
VAR _StartOfPeriod = MIN('Date'[Date])
VAR _EndOfPeriod = MAX('Date'[Date])
VAR _Result =
IF( 1=1,
VAR _EmployeesAtStart =
CALCULATETABLE(
VALUES(page[Employee Name]),
page[Last Hire Date] <= _StartOfPeriod,
page[Termination Date] >= _StartOfPeriod || ISBLANK(page[Termination Date])
)
VAR _EmployeesAtEnd =
CALCULATETABLE(
VALUES(page[Employee Name]),
page[Last Hire Date] <= _EndOfPeriod,
page[Termination Date] >= _EndOfPeriod || ISBLANK(page[Termination Date])
)
VAR _NoOFEmployeesAtStartAndEnd =
COUNTROWS(
INTERSECT(_EmployeesAtStart, _EmployeesAtEnd)
)
RETURN
DIVIDE(_NoOFEmployeesAtStartAndEnd, COUNTROWS(_EmployeesAtStart))
)
RETURN
_Result

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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!

December 2024

A Year in Review - December 2024

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