Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Filter - ALL, ALLSELECTED, ALLEXCEPT

I use the formula below to calculate change from previous week.  This works well when no filters are applied (or only applied to the 3 categories I have in the formula - NAME, BRAND and active_status).  Is there a way to make this work regardless of what filters are applied?  I can inlude every possible filter category in the formula, but it seems like there should be an easier way.  I've tried variations of ALL, ALLSELECTED and ALLEXCEPT, but nothing has worked so far.

 

CHANGE =
    VAR lastWeekAmount =
    CALCULATE (
         [COMPLETE %],
        FILTER(ALLEXCEPT('Stop', Core[NAME], Core[BRAND], Core[active_status]), Stop[TOTAL WEEK #]
                = MIN (Stop[TOTAL WEEK #])-1))
RETURN
    [COMPLETE %] - lastWeekAmount
  • hi Anonymous 

    You could try this formula

    CHANGE =
    VAR lastWeekAmount =
        CALCULATE (
            [COMPLETE %],
            FILTER (
                ALL ( Stop[TOTAL WEEK #] ),
                Stop[TOTAL WEEK #]
                    = MIN ( Stop[TOTAL WEEK #] ) - 1
            )
        )
    RETURN
        [COMPLETE %] - lastWeekAmount

     

    or

     

    CHANGE =
    VAR lastWeekAmount =
        CALCULATE (
            [COMPLETE %],
            FILTER (
                ALLSELECTED ( 'Stop' ),
                Stop[TOTAL WEEK #]
                    = MIN ( Stop[TOTAL WEEK #] ) - 1
            )
        )
    RETURN
        [COMPLETE %] - lastWeekAmount

     

    If not your case, just share a simple sample pbix file and the expected output in different scenarios.

     

    Regards,

    Lin

1 Reply

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi Anonymous 

    You could try this formula

    CHANGE =
    VAR lastWeekAmount =
        CALCULATE (
            [COMPLETE %],
            FILTER (
                ALL ( Stop[TOTAL WEEK #] ),
                Stop[TOTAL WEEK #]
                    = MIN ( Stop[TOTAL WEEK #] ) - 1
            )
        )
    RETURN
        [COMPLETE %] - lastWeekAmount

     

    or

     

    CHANGE =
    VAR lastWeekAmount =
        CALCULATE (
            [COMPLETE %],
            FILTER (
                ALLSELECTED ( 'Stop' ),
                Stop[TOTAL WEEK #]
                    = MIN ( Stop[TOTAL WEEK #] ) - 1
            )
        )
    RETURN
        [COMPLETE %] - lastWeekAmount

     

    If not your case, just share a simple sample pbix file and the expected output in different scenarios.

     

    Regards,

    Lin