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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
jmateu88
Helper I
Helper I

Get values from previous year from today

Hello,
after some research without success, I decided to do my first post in this platform.

What I'm looking for, is to be able to know the variation of a measure from previous years considering that today is the beginning of the year 0 and, one year ago, was the beginning of ther year 1. Obviously, each day has to be dynamic and this will be chanching.

 The aim of this, is to be able to know the variation of the pieces in a warehouse considering what has happened (which variation) during  the last years.

So that, I am not interested what happened in 2021 or 2020, etc. What I am interested in is knowing which variation occured during the previous periods always considering the current date.

It is very simple with PARALELLPERIOD, SAMEPERIODLASTYEAR and DATEADD for natural years but, I got stucked trying to get this in this specific way.

I also created in the calendar a new column with YEARFRAC & round to have this variation in the calendar specified... but there was not way to emulate the result given in  the typical case with the functions of time intelligence.

Thank you very much in advance!


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

Hi, @jmateu88 ;

Try it .

Measure =
CALCULATE (
    [select_almacen],
    FILTER ( ALL ( 'table' ), [YEAR_FRAC] = MAX ( 'table'[YEAR_FRAC] ) + 1 )
)

If the above one can't help you get the desired result, please provide some sample data in your tables (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 _ Yalan Wu
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

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @jmateu88 ;

Try it .

Measure =
CALCULATE (
    [select_almacen],
    FILTER ( ALL ( 'table' ), [YEAR_FRAC] = MAX ( 'table'[YEAR_FRAC] ) + 1 )
)

If the above one can't help you get the desired result, please provide some sample data in your tables (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 _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

it works PERFECTLY!
You did it easy something it seemed complicated. Bravo!!

Thank you very much.

jmateu88
Helper I
Helper I

Thank you for your reply Amit but it is not what I am looking for.
To use one table would not be suitable because I need this for lots of cases.

In order to simplify it. I put an easy example:
What I want, is something which allows me to get the values with an arrow;
wanted.jpg

This is the typical which I am not interested.
not_wanted.jpg
Thank you anyway!

jmateu88
Helper I
Helper I

Better with a picture. In the upper case, is considering the natural years which is okay.

The second table, is where we can see that the method is incorrect.

example.png

@jmateu88 , with help from date table and time intelligence

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

or

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))

 

Below can be done with year table too

//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

refer TI based on today

https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27...

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.