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
Anonymous
Not applicable

DATEADD Function

I am looking to calculate the average of previous year and the only date not showing correctly is 2021. I used an averagex function to determine the average cost(I've also tried using the divide function). (2021 is the only year not showing correctly for previous year, when i select 2021 using a filter for "Average Cost Per Part" is correct)

Average Cost Per Part=
AVERAGEX(
'All Spend Data',
'All Spend Data'[Ext Price]**
)
---------------------------------

Previous Year Average Cost =
CALCULATE(
[Average Cost Per Transaction],
DATEADD('Calendar'[Date], -1, YEAR)
)

2 ACCEPTED SOLUTIONS
lukiz84
Memorable Member
Memorable Member

insted of DATEADD use PREVIOUSYEAR

View solution in original post

Anonymous
Not applicable

Hi, this works if I have the time intelligence "auto date/time" is checked on but the previousyear worked without it! Thanks for your help!

 

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Please update the formula of measure [Previous Year Average Cost] as below and check if it can get the correct result... You can find the details in the attachment.

Previous Year Average Cost = 
CALCULATE (
    [Average Cost Per Part],
    FILTER (
        ALLSELECTED ( 'All Spend Data' ),
        YEAR ( 'All Spend Data'[Date] )
            = SELECTEDVALUE ( 'All Spend Data'[Date].[Year] ) - 1
    )
)

yingyinr_0-1666939093737.png

 

If the above one can't help you get the desired result, please provide some sample data in your table 'All Spend Data' (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.
Anonymous
Not applicable

Hi, this works if I have the time intelligence "auto date/time" is checked on but the previousyear worked without it! Thanks for your help!

 

lukiz84
Memorable Member
Memorable Member

insted of DATEADD use PREVIOUSYEAR

Anonymous
Not applicable

Appreciate the help, I got so stuck in using the dateadd and forgot about the previousyear; which worked perfectly. Thanks for your help!

 

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.