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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
zraopingm
Helper IV
Helper IV

YOY CHANGE FOR FIRST YEAR

Hello, 

image 1, is a matrix report with reporting year in column, with 2025 and 2026 year..

rather than using time intelligence, I attempted to use new visual cal. to get the change between years by using image2 formula..

since 2025 is the beginning of the year in this visual, YOY change should be blank.. so i used image 3.. 

but i got the error message in image 3.. can someone point out where I went wrong? 

thank you Zoey

zraopingm_0-1749148584123.png

 

zraopingm_1-1749148598028.png

 

 

zraopingm_2-1749148614405.png

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @zraopingm ,

Thank you for reaching out to the Microsoft Fabric Community forum.

 

Please follow below steps.

1. Created sample table (Table) with sample data.

vdineshya_0-1749210684353.png

 

2. Created Measure (Total Amount) with below DAX code.

Total Amount = SUM('Table'[TOTAL AMOUNT1])

3. Created visual calculation with below DAX code.

YOY CHANGE =
VAR PrevAmount =
CALCULATE(
[Total Amount],
OFFSET(-1, ORDERBY([Reporting Year]))
)
RETURN
IF(
ISBLANK(PrevAmount),
BLANK(),
[Total Amount] - PrevAmount
)

4. Please refer output snap, sample data and attached PBIX file.

vdineshya_1-1749210759847.png

 

If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

View solution in original post

7 REPLIES 7
v-dineshya
Community Support
Community Support

Hi @zraopingm ,

Thank you for reaching out to the Microsoft Fabric Community forum.

 

Please follow below steps.

1. Created sample table (Table) with sample data.

vdineshya_0-1749210684353.png

 

2. Created Measure (Total Amount) with below DAX code.

Total Amount = SUM('Table'[TOTAL AMOUNT1])

3. Created visual calculation with below DAX code.

YOY CHANGE =
VAR PrevAmount =
CALCULATE(
[Total Amount],
OFFSET(-1, ORDERBY([Reporting Year]))
)
RETURN
IF(
ISBLANK(PrevAmount),
BLANK(),
[Total Amount] - PrevAmount
)

4. Please refer output snap, sample data and attached PBIX file.

vdineshya_1-1749210759847.png

 

If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

it worked!!! and making sense and I learned a lot.

i have no clue i can use VAR in Visual cal. thank you thank you all!!! 

have a great DAX day!! 

danextian
Super User
Super User

Hi @zraopingm 

 

Please try this:

Previous Year = 
PREVIOUS([Total Revenue], 1, COLUMNS)

YOY =
VAR _PY =
    PREVIOUS ( [Total Revenue], 1, COLUMNS )
RETURN
    IF ( NOT ( ISBLANK ( _PY ) ), [Total Revenue] - _PY )

danextian_0-1749206476830.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
pankajnamekar25
Super User
Super User

Hello @zraopingm 

 

try this measure

YOY CHANGE =

VAR CurrentYear = SELECTEDVALUE('Reporting Year'[Year])

VAR PrevYear = CurrentYear - 1

VAR CurrentAmount = [TOTAL AMOUNT]

VAR PrevAmount =

    CALCULATE(

        [TOTAL AMOUNT],

        'Reporting Year'[Year] = PrevYear

    )

RETURN

IF(

    ISBLANK(PrevAmount),

    BLANK(),

    CurrentAmount - PrevAmount

)

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

Nasif_Azam
Super User
Super User

Hey @zraopingm ,

Thanks, Zoey! The issue you're facing arises from how you're referencing Reporting Year in your DAX formula using OFFSET and ORDERBY. Let's break this down and fix the issue.

 

The Core Error
In your third image, the error states: “Reporting Year is not a valid value for the RESET parameter, as it is not present in the visual axes.”

This tells us that while Reporting Year is visible in the matrix, it's not explicitly in the row or column axes of the visual calculation context (especially for OFFSET, which depends on a well-scoped column axis).

 

Your Current DAX (from Image 2)

YOY CHANGE = 
[TOTAL AMOUNT1] - 
CALCULATE(
    SUM([TOTAL AMOUNT1]), 
    OFFSET(-1, ORDERBY([Reporting Year]))
)

This syntax is almost correct, but OFFSET and ORDERBY only work properly if the column being used ([Reporting Year]) is in the visual axes, and properly scoped for each calculation context.

 

Fix Approach
You need to add SELECTCOLUMNS and REMOVEFILTERS to better scope the Reporting Year context for the OFFSET function to work correctly.

Try the following revised visual calculation:

YOY CHANGE =
IF(
    ISFILTERED('YourDateTable'[Reporting Year]), 
    [TOTAL AMOUNT1] -
    CALCULATE(
        SUM([TOTAL AMOUNT1]),
        OFFSET(
            -1,
            ORDERBY('YourDateTable'[Reporting Year]),
            PARTITIONBY([DIR IND CODE])
        )
    )
)

Or if you're using a visual calculation in Power BI's Quick Measure interface, try:

YOY CHANGE =
VAR CurrentAmount = [TOTAL AMOUNT1]
VAR PrevAmount =
    CALCULATE(
        [TOTAL AMOUNT1],
        OFFSET(
            -1,
            ORDERBY('YourDateTable'[Reporting Year]),
            PARTITIONBY([DIR IND CODE])
        )
    )
RETURN
    IF(
        ISINSCOPE('YourDateTable'[Reporting Year]) && 
        NOT ISBLANK(PrevAmount),
        CurrentAmount - PrevAmount
    )

 

Things to Remember:

  • Use PARTITIONBY if you want to calculate change within each DIR IND CODE.
  • Make sure Reporting Year is a proper column in your Date table and is used consistently in the matrix columns.
  • Avoid using Reporting Year directly without scoping when OFFSET is involved.
  • ISINSCOPE ensures your first year (2025) stays blank in YOY.

 

If Still Error:

Ensure:

  • The matrix uses 'YourDateTable'[Reporting Year] from the proper date dimension table.

  • You do not use a calculated column like YEAR([Date]) from fact tables.

  • The column is not renamed in the model, e.g., if it's just "Year" in the model, use that exact name.

 

If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


Best Regards,
Nasif Azam



Did I answer your question?
If so, mark my post as a solution!
Also consider helping someone else in the forums!

Proud to be a Super User!


LinkedIn

Thank you! 

I did use the measure to solve the issue, but at the same time trying to figure this out in visual cal. for learning.  this is straight downloaded without date table so I used your idea. and got this error message:. 

the goal is yoy change for 2025 should be blank since 2024 is filtered out.  If there is no prev. reporting year, then yoy change is zero or blank.  Thank you for your time 

 

zraopingm_0-1749155287215.png

 

 

 

Thanks again for the thoughtful reply! I really appreciate your goal of learning how to use Visual Calculations effectively instead of defaulting to measures it’s an awesome way to push your DAX skills further.

 

The Error:

The error in the screenshot says:

"Column reference cannot be used unless it is guaranteed to be unique in the context."

This usually happens because you're using 'DIR IND CODE' inside a visual calculation context without wrapping it properly. Unlike measures where filters are naturally applied, visual calcs need explicit context scoping to resolve columns like this.

 

Fixing the Visual Calculation:

You’re already using the right idea with OFFSET() and ORDERBY(), but here’s how to fully scope the context:

YOY CHANGE = 
VAR CurrentAmount = [TOTAL AMOUNT1]
VAR PrevAmount =
    CALCULATE(
        [TOTAL AMOUNT1],
        OFFSET(
            -1,
            ORDERBY('YourTableName'[Reporting Year]),
            PARTITIONBY('YourTableName'[DIR IND CODE])
        )
    )
RETURN
    IF(
        ISINSCOPE('YourTableName'[Reporting Year]) &&
        NOT ISBLANK(PrevAmount),
        CurrentAmount - PrevAmount
    )

 

Key Fixes:

  • Wrap [DIR IND CODE] in PARTITIONBY() instead of directly referencing it.

  • Make sure both Reporting Year and DIR IND CODE come from a single table (not calculated/renamed columns from other tables).

  • ISINSCOPE() safely blanks out the first year (like 2025) if no previous year exists.

 

Things to Remember:

  • If your data doesn't come from a date table, make sure Reporting Year is a numeric or ordered column otherwise ORDERBY() won’t behave as expected.

  • If TOTAL AMOUNT1 is a measure, you're good. If it's a column, you’ll need to change SUM([TOTAL AMOUNT1]) to match your logic.

  • If you're still getting errors, try using SELECTCOLUMNS or REMOVEFILTERS to ensure the context is clean.

 

If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


Best Regards,
Nasif Azam



Did I answer your question?
If so, mark my post as a solution!
Also consider helping someone else in the forums!

Proud to be a Super User!


LinkedIn

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.