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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.