Forum Discussion

mmills2018's avatar
mmills2018
Helper IV
5 years ago

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.

 

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

  • selimovd's avatar
    selimovd
    Most Valuable Professional

    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
     
    • mmills2018's avatar
      mmills2018
      Helper IV

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

    • mmills2018's avatar
      mmills2018
      Helper IV

      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?
  • Anonymous's avatar
    Anonymous
    Not applicable

    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