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

How to bring previous year/month value.

Hello Team,

 

How to bring previous year/month value based on current FY filter.

 

Refer the below snap for reference.
Capture.JPGPlease help here.

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You can create calendar table first of all, then create relationship between your data table and calendar table on date field.

 

Calendar = CALENDAR(MIN(Table1[Date]),MAX(Table1[Date]))  
 
Or
 
Calendar =CALENDARAUTO()

Secondly, you may create measure to get previous year/month value using DAX below.

 

Measure1= CALCULATE(SUM(Table1[Sales]),DATEADD('Calendar'[Date],-12,MONTH))

Best Regards,

Amy

 

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

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You can create calendar table first of all, then create relationship between your data table and calendar table on date field.

 

Calendar = CALENDAR(MIN(Table1[Date]),MAX(Table1[Date]))  
 
Or
 
Calendar =CALENDARAUTO()

Secondly, you may create measure to get previous year/month value using DAX below.

 

Measure1= CALCULATE(SUM(Table1[Sales]),DATEADD('Calendar'[Date],-12,MONTH))

Best Regards,

Amy

 

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

kentyler
Solution Sage
Solution Sage

Your first step is to use Power Query to reshape your data so that the year/month becomes a row value instead of a column header

Code |  Name |  Year/Month  | Value

 

If you use a date for year/month then you can use something like the techniques described in this post https://radacad.com/previous-dynamic-period-dax-calculation

 

It's a step further, but you might think about adding a Calendar Table and creating a relationship to your fact table. That way if you are missing data for a year/month it will still show up in your reports. You can google Calendar Table and find many ways to make one. They are exremely useful in DAX





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


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.