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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
unusdusrname
Frequent Visitor

Show value as % of previous

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.

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

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 )
    )

yingyinr_0-1663210892699.png

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
unusdusrname
Frequent Visitor

Thankyou very much Rena.

v-yiruan-msft
Community Support
Community Support

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 )
    )

yingyinr_0-1663210892699.png

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors