Forum Discussion
Last Month Data
Hello I have a very simple issue,
Below is the data set,
I always need previous month count, like in current month. I need September data. PLease help.
15 Replies
- edhansCommunity Champion
You need to create a date table for this to work, then it is a very simple solution.
- Create a date table. I just explained the easiest way to do this in another post today.
- Relate the Date field in the date table to the date field in your data set.
- Drag the date from the Date table (not your data set) to the table or matrix visual you are using.
- Create this measure (it assumes you have another measure Total Sales that is something like = SUM(SalesData[Sales])):
=CALCULATE( [Total Sales], PREVIOUSMONTH('Calendar'[Date]) )
That will calculate your sales for the previous month. edit: fixed an extra comma in my formula above. Now it works. :-)
- AnonymousNot applicable
Thanks yes, I have a date table which connects with other data table
Here is my measure = TOTAL_SALES = SUMX(Filter('SALES_TABLE','SALES_TABLE'[COLOR]="Blue"),'SALES_TABLE'([Amt])
Measure 2 = CALCULATE ([TOTAL_SALES], PREVIOUSMONTH('DATE_Table'[Date_Key]))
But as you can see, it returens all the previous months, if I remove Year_Month column, it dows not show any data
- edhansCommunity Champion
I don't understand what you mean by "it returns all of the previous months." It should. It isn't cumulative. March will show Feb, Feb will show Jan, Jan will show Dec of previous year.
Show me exactly what the issue is, as you only showed "Measure 2" and not "Total Sales"
The first thing to check though is make sure any date data in your table is coming from the Date table, not the date field in your sales table. The date intelligence functions require the Calendar/Date table to be used in the visuals to work right.