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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Is there a measure to automate current and previous year from date column and do the calculations?

Is there a measure to automate current and previous year from date column and do the calculations?

I have past 2 years data and the data will add on every day and I have done all the measures on the year 2017 and 2018. Now the problem raised, when the data for 2019 is added into the sheet is it not fetching it. it is taking 2017 and 2018. I need a measure which will take previous year and current year automatically when new data is added and removes the old data(if possible).

all the calcualtion will automatically change as per the previous and current year.

 

Thanks in advance.

 

Regards

Phaneendra

5 REPLIES 5
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Employee
Employee

Hi Phaneendra,

 

Can you share a sample, please? Please mask the private data.

The DAX function is dynamic. It will calculate the new data automatically. What is your scenario? If the Power BI doesn't get the new data, you need to refresh the report or dataset.

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

datedetailssales
1/01/2017a45
1/02/2017s646
1/05/2017d36
5/06/2017f1
9/12/2017g4
1/01/2018h464
5/12/2018rtr3
6/01/2018cv13
9/01/2018df316
1/01/2019f3
2/01/2019re1

 

today we are in 2018 and I have return a measure as 2017 total - 2018 total and in next year if we add 2019 data, the measure where I have return 2017 and 2018 will fail. What I have to do so that the PBI will automtically change 2019 has current year and 2018 has previous year. I simple on 2 jan 2019 if I run the report it should take the measure as 2018 - 2019(insted of 2017 -2018). Hope I am clear.
I need a measure where It will directly take all 2017 has previous and 2018 has current year. and In next year 2018 has previous year and 2019 has current year.

Hope I am clear.

Hi @Anonymous,

 

Do you have a Date table? If so, the formulas could be like below.

 

previous =
CALCULATE ( SUM ( 'table'[sales] ), PREVIOUSYEAR ( 'date'[date] ) )
current = sum('table'[sales])

 

Best Regards,
Dale

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

Hi,

 

Create a Calendar Table and build a relationship between the Date column of your base data table to the Date column of the Calendar Table.  In the Calendar Table, create these calculated column formulas: Year=Year(Calendar[Date]) and Month=FORMAT(Calendar[Date],"mmmm").  In your visual, drag Year from the Calendar Table.  Write this measure

 

=SUM(Data[Sales])

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors