Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
curtismob
Helper IV
Helper IV

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.

 

curtismob_0-1693844348695.png

 

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 

 

1 ACCEPTED SOLUTION

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
 
Pady_0-1693945850121.png

 

 

View solution in original post

8 REPLIES 8
Pady
Helper II
Helper II

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

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

 

@curtismob 

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

Sorry, I am unable to find the  pbix file in any of the folders. Could you please send the link for the pbix file?

 

Is this what you see when clciking the link?  Is the download icon available?

curtismob_0-1693945642509.png

 

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
 
Pady_0-1693945850121.png

 

 

The latest change worked, thank you for your help!!

 

@curtismob 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.