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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Calculate Year to Year Difference without Time Series Data

Hi everyone,

 

Apologies for reposting a similar issue. I've gone through several previous posts and solutions shared by others regarding this common problem, but unfortunately, I haven't been able to apply any of them successfully to my specific context.

 

Context: I'm trying to calculate the difference between the selected year (via slicer) and the prior year.

 

Problem: The matrix correctly displays data for the selected year but shows nothing for the prior year.

 

Attempts so far:
I've tried multiple approaches, including adding a prior_year column in the dim_time table and experimenting with various DAX formulas. Below is my latest DAX attempt, which still doesn’t work as expected.

 

UOM_difference =
VAR SelectedYear = SELECTEDVALUE(dim_time[year])
VAR PriorYear = SelectedYear - 1

 

VAR UOM_Selected_Year = CALCULATE(
SELECTEDVALUE(financial[UOM %]),
FILTER(dim_time, dim_time[year] = SelectedYear &&
(dim_time[period] = "FY" || dim_time[period] = "H1")),
FILTER(dim_region, dim_region[region_name] = "Global")
)

 

VAR Prior_Year = CALCULATE(
SELECTEDVALUE(financial[UOM %]),
REMOVEFILTERS(dim_time[year]),
FILTER(dim_time, dim_time[year] = PriorYear &&
(dim_time[period] = "FY" || dim_time[period] = "H1")),
FILTER(dim_region, dim_region[region_name] = "Global")
)

 

RETURN IF(NOT ISBLANK(UOM_Selected_Year) && NOT ISBLANK(Prior_Year),
(UOM_Selected_Year - Prior_Year) * 100,
BLANK()
)


Thank you for looking through my issue. I'd appreciate it if you could drop any explanation/hint/solution on this issue.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try this:

UOM_Prior_Year 1 = 
    VAR SelectedYear = SELECTEDVALUE(dim_time[year])
    VAR PriorYear = SelectedYear - 1
    VAR __Company = MAX( 'dim_company'[company_id] )
    VAR __Dates = SELECTCOLUMNS( FILTER( ALL( 'dim_time' ), [period] = "FY" || dim_time[period] = "H1"), "Date", [date_key] )
    VAR __Regions = SELECTCOLUMNS( FILTER( ALL( 'dim_region' ), dim_region[region_name] = "Global" ), "Region", [region_id] )
    VAR __Table = FILTER( ALL( 'financial' ), [date_key] IN __Dates && [region_id] IN __Regions && [company_id] = __Company )
    VAR __Result = SUMX( __Table, [UOM %] ) 
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try this:

UOM_Prior_Year 1 = 
    VAR SelectedYear = SELECTEDVALUE(dim_time[year])
    VAR PriorYear = SelectedYear - 1
    VAR __Company = MAX( 'dim_company'[company_id] )
    VAR __Dates = SELECTCOLUMNS( FILTER( ALL( 'dim_time' ), [period] = "FY" || dim_time[period] = "H1"), "Date", [date_key] )
    VAR __Regions = SELECTCOLUMNS( FILTER( ALL( 'dim_region' ), dim_region[region_name] = "Global" ), "Region", [region_id] )
    VAR __Table = FILTER( ALL( 'financial' ), [date_key] IN __Dates && [region_id] IN __Regions && [company_id] = __Company )
    VAR __Result = SUMX( __Table, [UOM %] ) 
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler 

Thank you for your prompt solution. I appreciate it a lot 😁

Anonymous
Not applicable

PBIX LINK: HERE

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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