Forum Discussion

curtismob's avatar
curtismob
Icon for Helper IV rankHelper IV
3 years ago
Solved

Override Year Slicer For Previous Measure

Hello, I have a matrix with monthly costs, along with the variances from month to month.  I have a slicer to select the year, but I also want to inlcude the cost for the previous December, in order to calculate the Decemeber Prior Year/January variance.  See screen shot below.

 

 

Prior December measure:

 

DecCostPriorYr =
VAR YearSelectedLessOne =
SELECTEDVALUE(PlanCost[Year]) - 1

VAR CostCalc =
CALCULATE(SUM(PlanCost[Cost]),
FILTER(ALL(PlanCost),
PlanCost[Month] = 12 &&
PlanCost[Year] = YearSelectedLessOne))

RETURN
CostCalc

 

Here is the link to the pbix.

 

https://drive.google.com/file/d/1V1M0Dho5P7ICGhvXTBaPPwaUNpzOs1_E/view?usp=drive_link

 

Thank you in advance,

curtismob 

 

  • Pady's avatar
    Pady
    3 years ago

    Sorry about the previous post. The following formula works

    DecCostPriorYr =
    VAR YearSelectedLessOne =
    SELECTEDVALUE(PlanCost[Year]) - 1

    VAR CostCalc =
    CALCULATE(SUM(PlanCost[Cost]),
    FILTER(ALL(PlanCost[Community],PlanCost[Month],PlanCost[Year]),
    PlanCost[Month] = 12 && PlanCost[Year] = YearSelectedLessOne))

    RETURN
    CostCalc
     

     

     

8 Replies

  • Please change replace ALL with ALLSELECTED . Hope it works.

    DecCostPriorYr =

    VAR YearSelectedLessOne =

    SELECTEDVALUE(PlanCost[Year]) - 1

     

    VAR CostCalc =

    CALCULATE(SUM(PlanCost[Cost]),

    FILTER(ALLSELECTED(PlanCost),

    PlanCost[Month] = 12 &&

    PlanCost[Year] = YearSelectedLessOne))

     

    RETURN

    CostCalc

    • curtismob's avatar
      curtismob
      Icon for Helper IV rankHelper IV

      Thank you for the quick response.  Unfortunately, that did not work, all values are blank when using ALLSELECTED.

       

      curtismob 

      • Pady's avatar
        Pady
        Icon for Helper II rankHelper II

        Sorry, I am unable to access the Googledrive link. Could you change the permission to anyone with link can download?