Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello folks. I have some data which I'm displaying in a stacked column and line chart. My stacked columns are on split by fiscal year on the x axis.
I'm looking for a line to display the difference to the prior FY. I found my way to a new measure, and the application generated this code:
Total % difference from FY2022 =
VAR __BASELINE_VALUE = CALCULATE(SUM('Query1'[Total]), 'Query1'[fiscal year] IN { "FY2020" })
VAR __MEASURE_VALUE = SUM('Query1'[Total])
RETURN
IF(
NOT ISBLANK(__MEASURE_VALUE),
DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE)
)
So far so good, but I only have % difference to a specified FY, where I'm looking for FY-1. Possible values for FY are FY2020 FY2021 FY2022 FY2023 et seq. Seems odd that this functionality is readily available in en excel pivot table but doesn't seem to be here?
Grateful of guidance on how to make that IN {"FY2020"} be dynamic.
Cheers.
Solved! Go to Solution.
Hi @unusdusrname ,
You can update the formula of measure [Total % difference from FY2022] as below and check if it can return your expected result... Please find the details in the attachment.
Total % difference from FY2022 =
VAR _selfyear =
SELECTEDVALUE ( 'Query1'[fiscal year] )
VAR _year =
VALUE ( RIGHT ( _selfyear, 4 ) )
VAR __BASELINE_VALUE =
CALCULATE (
SUM ( 'Query1'[Total] ),
FILTER (
ALLSELECTED ( 'Query1' ),
VALUE ( RIGHT ( 'Query1'[fiscal year], 4 ) ) = _year - 1
)
)
VAR __MEASURE_VALUE =
SUM ( 'Query1'[Total] )
RETURN
IF (
NOT ISBLANK ( __MEASURE_VALUE ),
DIVIDE ( __MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE )
)
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. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Thankyou very much Rena.
Hi @unusdusrname ,
You can update the formula of measure [Total % difference from FY2022] as below and check if it can return your expected result... Please find the details in the attachment.
Total % difference from FY2022 =
VAR _selfyear =
SELECTEDVALUE ( 'Query1'[fiscal year] )
VAR _year =
VALUE ( RIGHT ( _selfyear, 4 ) )
VAR __BASELINE_VALUE =
CALCULATE (
SUM ( 'Query1'[Total] ),
FILTER (
ALLSELECTED ( 'Query1' ),
VALUE ( RIGHT ( 'Query1'[fiscal year], 4 ) ) = _year - 1
)
)
VAR __MEASURE_VALUE =
SUM ( 'Query1'[Total] )
RETURN
IF (
NOT ISBLANK ( __MEASURE_VALUE ),
DIVIDE ( __MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE )
)
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. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.