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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.