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

Cant get Previous months Data

Hi,

 

I have a table that has all the month end dates in and products along with there value for that month.

 

This table is linked to a calendar table (which is a date table). Many to one (both)

 

In the report I use the month and year from the calendar table to filter the data, this works fine for the month/year (one slicer is year and teh other is month) selected but when I try and show the previous months data alongside I just get blanks.

 

The data table (GetMRRdata_overall) structure is 

 

MonthEnd this is linked to date in Calendar

Product

Value

 

The calc I have tried is 

CALCULATE(SUM(GetMRRdata_overall[MRR]),FILTER(ALL(GetMRRdata_overall),GetMRRdata_overall[MonthEnd] = PREVIOUSMONTH('Calendar'[End Of Month Date]))).
 
Any help would be much appreciated 
 
Thank you

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

You can create a measure like DAX below.

 

PreviousMonth = CALCULATE(SUM(GetMRRdata_overall[MRR]),DATEADD('t_Calendar'[Date],-1,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

4 REPLIES 4
Anonymous
Not applicable

I Have tried the following but I only get the overall total against all the products not the individual totals :

 

Measure 3 = VAR SELECTED = MAX('Calendar'[End Of Month Date]) RETURN CALCULATE(SUM(GetMRRdata_overall[MRR]),FILTER(ALL(GetMRRdata_overall),GetMRRdata_overall[MonthEnd] =EOMONTH(SELECTED,-1)))
Anonymous
Not applicable

Think I have sorted it (I changed the calendar table name so it didnt confuse with preffered name, this wasnt the answer though)

 

PreviousMonth = CALCULATE(SUM(GetMRRdata_overall[MRR]),
DATESBETWEEN('t_Calendar'[Date],
FIRSTDATE(DATEADD('t_Calendar'[Date],-1,MONTH)),
IF(MONTH(MIN('t_Calendar'[Date])) = MONTH(SELECTEDVALUE(t_Calendar[End Of Month Date])), EOMONTH(SELECTEDVALUE(t_Calendar[End Of Month Date]),-1) , LASTDATE(DATEADD('t_Calendar'[Date],-1,MONTH)))
)
)

Hi @Anonymous ,

 

You can create a measure like DAX below.

 

PreviousMonth = CALCULATE(SUM(GetMRRdata_overall[MRR]),DATEADD('t_Calendar'[Date],-1,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.

Anonymous
Not applicable

Thank you Amy, this is much better 🙂

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.