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
mmills2018
Helper IV
Helper IV

Rolling 3 month calculation

Hello,

 

i am calculating rolling 3 month annualized turnover, but something is off.  My term count for March is 163, when i annualize 163 i get 652. My calculation is only annualzing March and not March and the 2 months prior.

turnover.png

 

here is my measure - any ideas how i can get it to sum Jan terms, feb terms, march terms and then annualize (X4)?

 

VAR LatestMonth = LASTDATE(Snapshots[Data as of])
VAR Prior3rdMonth = FIRSTDATE(DATESINPERIOD(Snapshots[Data as of],LatestMonth,-3,month) )
return
CALCULATE(DISTINCTCOUNTNOBLANK('Snapshots'[AssociateID]), 'Snapshots'[Gender]="Female",'Snapshots'[Alt Term Date]<>BLANK(), 'Snapshots'[TerminationPrimaryTerminationCategory]="Voluntary",'Snapshots'[TerminationBusinessProcessReason]<>"Retirement", 'Snapshots'[TerminationBusinessProcessReason]<>"Assignment/Contract End", 'Snapshots'[TerminationBusinessProcessReason]<>"Deceased", 'Snapshots'[TerminationBusinessProcessReason]<>"Did Not Start", 'Snapshots'[TerminationBusinessProcessReason]<>"Failure to Provide Required Employment Eligibility", DATESBETWEEN('Date Table'[Date],Prior3rdMonth,LatestMonth))*4
5 REPLIES 5
v-yuaj-msft
Community Support
Community Support

Hi @mmills2018 ,

 

Based on your description, the DAX formula you created does not seem to see any logical problems. 

Could you please share some sample data and the expected result to have a clear understanding of your question? I can do some tests for you. 😊 If the information is sensitive please share it after removing private message.

You can save your files in some cloud sharing platforms and share the link here.

How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

Best Regards,

Yuna

daxer-almighty
Solution Sage
Solution Sage

@mmills2018 

 

All the formulae in this thread are incorrect. This is because any time-intel function needs a real date table to work properly. Please read the documentation on DATESINPERIOD: https://dax.guide/datesinperiod 

thanks, my initial approach i did use a real data table, below is my measure:

 

VAR LatestMonth = LASTDATE('Date Table'[Date])
VAR Prior3rdMonth = FIRSTDATE(DATESINPERIOD(Snapshots[Data as of],LatestMonth,-3,month) )

return
CALCULATE(
DISTINCTCOUNTNOBLANK( 'Snapshots'[AssociateID] ),
'Snapshots'[Gender] = "Female",
'Snapshots'[Alt Term Date] <> BLANK(),
'Snapshots'[TerminationPrimaryTerminationCategory] = "Voluntary",
'Snapshots'[TerminationBusinessProcessReason] <> "Retirement",
'Snapshots'[TerminationBusinessProcessReason] <> "Assignment/Contract End",
'Snapshots'[TerminationBusinessProcessReason] <> "Deceased",
'Snapshots'[TerminationBusinessProcessReason] <> "Did Not Start",
'Snapshots'[TerminationBusinessProcessReason] <> "Failure to Provide Required Employment Eligibility",
DATESINPERIOD(
'Date Table'[Date],
LatestMonth,
-3,
MONTH
)
) * 4
 
and this is what i return.  The issue i am having is i want to calculate rolling 3 month annualized turnover by month, so for March i should see 1628, it is also only showing me 3 months of data, i want to see a years worth of data, so Feb would include Dec, Jan and Feb terms, but i need a moving rolling count.  any ideas on how to do this?
turnover1.png
selimovd
Super User
Super User

Hey @mmills2018 ,

 

I think your approach with the date calculation is a little too complicated. Just try to use DATESINPERIOD as a calculate modifier, that seems to be more easy and also more logical for me:

MyMeasure =
VAR LatestMonth =
    LASTDATE( Snapshots[Data as of] )
RETURN
    CALCULATE(
        DISTINCTCOUNTNOBLANK( 'Snapshots'[AssociateID] ),
        'Snapshots'[Gender] = "Female",
        'Snapshots'[Alt Term Date] <> BLANK(),
        'Snapshots'[TerminationPrimaryTerminationCategory] = "Voluntary",
        'Snapshots'[TerminationBusinessProcessReason] <> "Retirement",
        'Snapshots'[TerminationBusinessProcessReason] <> "Assignment/Contract End",
        'Snapshots'[TerminationBusinessProcessReason] <> "Deceased",
        'Snapshots'[TerminationBusinessProcessReason] <> "Did Not Start",
        'Snapshots'[TerminationBusinessProcessReason] <> "Failure to Provide Required Employment Eligibility",
        DATESINPERIOD(
            Snapshots[Data as of],
            LatestMonth,
            -3,
            MONTH
        )
    ) * 4

 

I presonally also would "clean up" the TerminationBusinessProcessReason with NOT IN, but that is optional 😉:

MyMeasure =
VAR LatestMonth =
    LASTDATE( Snapshots[Data as of] )
RETURN
    CALCULATE(
        DISTINCTCOUNTNOBLANK( 'Snapshots'[AssociateID] ),
        'Snapshots'[Gender] = "Female",
        'Snapshots'[Alt Term Date] <> BLANK(),
        'Snapshots'[TerminationPrimaryTerminationCategory] = "Voluntary",
        NOT ( 'Snapshots'[TerminationBusinessProcessReason]
            IN {
            "Retirement",
            "Assignment/Contract End",
            "Deceased",
            "Did Not Start",
            "Failure to Provide Required Employment Eligibility"
        } ),
        DATESINPERIOD(
            Snapshots[Data as of],
            LatestMonth,
            -3,
            MONTH
        )
    ) * 4

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

thanks! not sure why but when i do that, it removed my March term count, any ideas why?turnover1.png

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.