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
adamzu
New Member

The sameperoidlastyear function calculates the value for its year and not the previous year

Hi,

I'm having trouble writing a measure that calculates last year's value. Below is an image showing what I mean:

 

adamzu_0-1723017248916.png

I need the "Wolumen YA" measure to calculate growth in the current year relative to last year. For reasons I don't understand, the measure calculates the value for its year. Below is the measure:

 

Wolumen YA = CALCULATE([Wolumen], SAMEPERIODLASTYEAR(Dates[Date]))

 

Maybe someone has encountered a similar problem and will be able to explain what's wrong here.

 

 

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

Hi @adamzu 

 

Thanks for the reply from Greg_Deckler and HotChilli .

 

@adamzu , the following test is for your reference.

 

My sample:

vxuxinyimsft_1-1723192469897.png

 

Create several measures as follow

This year = SUM('Table'[Value])

The measure was created just to restore your scenario, as I don't know the creation logic of your Wolumen.

 

Measure = 
VAR _year = MAX([Year])
VAR _month = MAX([Month])
RETURN
CALCULATE([This year], FILTER(ALL('Table'), [Year] = _year - 1 && [Month] = _month))

 

Measure 1 = SUMX(VALUES('Table'[Month]), [Measure])

 

Last year = SUMX(VALUES('Table'[Year]), [Measure 1])

 

Output:

vxuxinyimsft_0-1723192431436.png

 

Best Regards,
Yulia Xu

 

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

3 REPLIES 3
v-xuxinyi-msft
Community Support
Community Support

Hi @adamzu 

 

Thanks for the reply from Greg_Deckler and HotChilli .

 

@adamzu , the following test is for your reference.

 

My sample:

vxuxinyimsft_1-1723192469897.png

 

Create several measures as follow

This year = SUM('Table'[Value])

The measure was created just to restore your scenario, as I don't know the creation logic of your Wolumen.

 

Measure = 
VAR _year = MAX([Year])
VAR _month = MAX([Month])
RETURN
CALCULATE([This year], FILTER(ALL('Table'), [Year] = _year - 1 && [Month] = _month))

 

Measure 1 = SUMX(VALUES('Table'[Month]), [Measure])

 

Last year = SUMX(VALUES('Table'[Year]), [Measure 1])

 

Output:

vxuxinyimsft_0-1723192431436.png

 

Best Regards,
Yulia Xu

 

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

HotChilli
Super User
Super User

What's in the matrix visual? Which tables are used in the model? What are the relationships?

What is the measure [Wolumen]?

Greg_Deckler
Super User
Super User

@adamzu You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

 

Also this: (1) Better Year Over Year Change - Microsoft Fabric Community


Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Also, this video demonstrates numerous different ways to calculate time intelligence measures:



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.