Forum Discussion
Anonymous
2 years agoNot applicable
Sum using slicer
Hello Power Bi community, i have data in below format: Year Month Sales Profit 2023 1 24 11 2023 2 56 33 2023 2 76 22 2023 1 78 66 2023 2 98 33 2022 2 76 ...
- 2 years ago
Anonymous
I modified the year to accommodate 2024:Sales Compared Year = VAR __CurrentYear = SELECTEDVALUE( Table22[Year]) VAR __Year = SWITCH( __CurrentYear, 2022 , 2023, 2023, 2022, 2024 , 2023 ) VAR __Months = VALUES( Table22[Month] ) VAR __Result = CALCULATE( [Selected Year Sales], Table22[Year] = __Year, __Months ) RETURN
Anonymous
2 years agoNot applicable
Hi Fowmy ,
Thanks for the response.
With 3 years of data(2022,2023,2024),
When we select 2022 in the slicer : 2022 will be the current year and 2023 will be compared year.
When we select 2023 in the slicer: 2023 will be current year and 2022 will be compared year(As we don't have full year of 2024 data so we will be comparing it with 2022 only.).
When we select 2024 in slicer: 2024 will be current year and 2023 will be compared year.
Thanks in advance.
Fowmy
Super User
2 years agoAnonymous
I modified the year to accommodate 2024:
Sales Compared Year =
VAR __CurrentYear = SELECTEDVALUE( Table22[Year])
VAR __Year =
SWITCH(
__CurrentYear,
2022 , 2023,
2023, 2022,
2024 , 2023
)
VAR __Months = VALUES( Table22[Month] )
VAR __Result =
CALCULATE(
[Selected Year Sales],
Table22[Year] = __Year,
__Months
)
RETURN- Anonymous2 years agoNot applicable
I am getting belwo error while using above created measure in the calculation:
what should i do?