Forum Discussion
visual calculation Previous in wrong column
- Anonymous1 year ago
Thanks for Kedar_Pande's concern about this issue.
Hi, Anonymous
I am glad to help you.
Since you didn't give specific datasets for testing, I assumed some datasets myself:
I don't know if you have to use the Previous function, in my tests I didn't use that function and recreated two Measure:
previous year = DIVIDE( SUM('Table'[count]), CALCULATE( SUM('Table'[count]), ALLEXCEPT('Table', 'Table'[Year]) ), 0 )diff prev year = VAR _CurrentYear = 2024 VAR _PreviousYear = 2023 VAR _CurrentYearPercentage = CALCULATE( [previous year], FILTER('Table', 'Table'[Year] = _CurrentYear) ) VAR _PreviousYearPercentage = CALCULATE( [previous year], FILTER('Table', 'Table'[Year] = _PreviousYear) ) RETURN IF( MAX('Table'[Year]) = _PreviousYear, 0, _CurrentYearPercentage - _PreviousYearPercentage )
Finally I got the result you need:If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for Kedar_Pande's concern about this issue.
Hi, Anonymous
I am glad to help you.
Since you didn't give specific datasets for testing, I assumed some datasets myself:
I don't know if you have to use the Previous function, in my tests I didn't use that function and recreated two Measure:
previous year =
DIVIDE(
SUM('Table'[count]),
CALCULATE(
SUM('Table'[count]),
ALLEXCEPT('Table', 'Table'[Year])
),
0
)
diff prev year =
VAR _CurrentYear = 2024
VAR _PreviousYear = 2023
VAR _CurrentYearPercentage =
CALCULATE(
[previous year],
FILTER('Table', 'Table'[Year] = _CurrentYear)
)
VAR _PreviousYearPercentage =
CALCULATE(
[previous year],
FILTER('Table', 'Table'[Year] = _PreviousYear)
)
RETURN
IF(
MAX('Table'[Year]) = _PreviousYear,
0,
_CurrentYearPercentage - _PreviousYearPercentage
)
Finally I got the result you need:
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.