cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
adam_macs
Regular Visitor

Using selectedvalue to determine previous year and pass to variable

Hi, below measure is essentially trying to determine the sales for the year before the one the user has selected.

 

i am using VAR selected_assessmentYear  to determine the year that the user has selected in the slicer and then subtracting 1 to determine the previous year. 

 

When i test VAR selected_assessmentYear in a separate measure, it works fine and successfully shows the previous year. However when i pass it to the Finance_Sales[AcademicYear] section it doesn't seem to work and reverts to the year they user has selected instead. 

adam_macs_1-1635175258559.png

 

Order Value (Previous AY) = 
VAR selected_assessmentYear = SELECTEDVALUE( Finance_Sales[AcademicYear].[Year],0)-1
RETURN
CALCULATE(
SUM(Finance_Sales[NetValueBasedOnCommitment]),
YEAR(
Finance_Sales[AcademicYear] = selected_assessmentYear))
1 ACCEPTED SOLUTION

figured it out....below for anyone interested

 

AY Test Year = 
VAR previousYR = SELECTEDVALUE( Finance_Sales[AcademicYear].[Year],0)-1
RETURN
CALCULATE (
[Net_Order_Value_(commit)],
FILTER (
ALL ( Finance_Sales ),
Finance_Sales[AcademicYear].[Year] = previousYR))

View solution in original post

4 REPLIES 4
PaulOlding
Super User
Super User

The position of the brackets doesn't look right in this line:

YEAR(Finance_Sales[AcademicYear] = selected_assessmentYear))

Shouldn't you have a closing round bracket after [AcademicYear]?

 

 

 

hi @PaulOlding, nope im afraid that didnt do it. When i insert insert closing brackets around the academic year it returns null. 

figured it out....below for anyone interested

 

AY Test Year = 
VAR previousYR = SELECTEDVALUE( Finance_Sales[AcademicYear].[Year],0)-1
RETURN
CALCULATE (
[Net_Order_Value_(commit)],
FILTER (
ALL ( Finance_Sales ),
Finance_Sales[AcademicYear].[Year] = previousYR))

View solution in original post

Do you have some example data you can share?

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors