Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dax help Monthly annualised ℅

12Month Rolloing Attr%=CALCULATE([12 month Attrition Nos]/[12 month Avg Billable No], FILTER('Calendar', 'Calendar'[Date]>= date(2016,12,1))) I hv data frm jan16 onwards, above formula works fine frm...
  • v-lid-msft's avatar
    v-lid-msft
    7 years ago

    Hi Anonymous ,

     

    Sorry for not understand your requirement clearly, now I have fixed my formula, We can use the following measure to archive your requirement:

     

    Test =
    VAR selectedtime =
        MAX ( 'Calendar'[Date] )
    VAR starttime =
        CALCULATE (
            MIN ( 'BillableNos'[Month] ),
            FILTER (
                ALL ( BillableNos ),
                AND (
                    AND (
                        'BillableNos'[Billable Nos] > 0,
                        NOT ISBLANK ( BillableNos[Billable Nos] )
                    ),
                    BillableNos[Sow Name] IN FILTERS ( 'SOWMaster'[SOW] )
                )
            )
        )
    VAR starttimemonth =
        DATE ( YEAR ( starttime ), MONTH ( starttime ), 1 )
    VAR t =
        ADDCOLUMNS (
            ADDCOLUMNS (
                DISTINCT ( ALLSELECTED ( BillableNos[Month] ) ),
                "MonthBill", CALCULATE (
                    SUM ( BillableNos[Billable Nos] ),
                    FILTER ( ALLSELECTED ( 'BillableNos' ), [Month] = EARLIER ( [Month] ) )
                ) + 0
            ),
            "MonthNo", CALCULATE (
                COUNT ( ActualAttritionRaw[Attrition Gross/Net] ),
                FILTER (
                    ALLSELECTED ( ActualAttritionRaw ),
                    AND (
                        ActualAttritionRaw[Attrition Gross/Net] = "Net",
                        AND (
                            MONTH ( ActualAttritionRaw[Last Working Day] ) = MONTH ( [Month] ),
                            YEAR ( ActualAttritionRaw[Last Working Day] ) = YEAR ( [Month] )
                        )
                    )
                )
            ) + 0
        )
    VAR t1 =
        ADDCOLUMNS (
            t,
            "MonthAtt", IF ( [Month] < starttimemonth, BLANK (), DIVIDE ( [MonthNo], [MonthBill], 0 ) )
        )
    RETURN
        IF (
            selectedtime < starttimemonth,
            BLANK (),
            IF (
                selectedtime < ( starttimemonth + 365 ),
                FORMAT (
                    AVERAGEX ( FILTER ( t1, [Month] <= selectedtime ), [MonthAtt] ) * 12,
                    "Percent"
                ),
                FORMAT (
                    DIVIDE (
                        SUMX (
                            FILTER ( t1, AND ( [Month] <= selectedtime, [Month] >= selectedtime - 365 ) ),
                            [MonthNo]
                        ),
                        AVERAGEX (
                            FILTER ( t1, AND ( [Month] <= selectedtime, [Month] >= selectedtime - 365 ) ),
                            [MonthBill]
                        ),
                        0
                    ),
                    "Percent"
                )
            )
        )

     


    BTW, pbix as attached.

     

    Best regards,

    Community Support Team _ Dong Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.