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

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.

2018-10-26_17-21-33.jpg

 

15 REPLIES 15
edhans
Super User
Super User

You need to create a date table for this to work, then it is a very simple solution.

  1. Create a date table. I just explained the easiest way to do this in another post today.
  2. Relate the Date field in the date table to the date field in your data set.
  3. Drag the date from the Date table (not your data set) to the table or matrix visual you are using.
  4. 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. 🙂



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not 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

all months.jpg

Hi,

 

What is the problem with this output?  What result are you expecting?


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

I just want to get one value SUM of Last Month, but it is returning sum of each month like 15 rows or so.

Anonymous
Not applicable

Not entirely clear on what you are looking for, but have you given OPENINGBALANCEMONTH or PARALLELPERIOD try?  

Anonymous
Not applicable

@AnonymousI'm looking for very simple output only sum of last month's sales.

Anonymous
Not applicable

@Anonymousand @Ashish_Mathur

 

Just trying to simplyfying my question

post.jpg

Anonymous
Not applicable

Let's see if this gets in the right direction:

Prev Month Sales.png

Anonymous
Not applicable

@AnonymousThanks Nick, but how do I get on previous month sum not the running total. Like In OCT I only wnat to see Sep totals.

Anonymous
Not applicable

You don't need to have the "Total Sales" measure in the table.  Removing that measure, and only having the Previous Month Sales, will show October on the row, but will have September's sales.  Though that could lead to some confusion.

Both Measures.png

Another idea could be to use ParallelPeriod, which shows the grand total of the previous month, regardless if you are at a lower granularity  

Para Period.png

Anonymous
Not applicable

@Anonymouscan I send you my PBIX, it is very simple file with 2 tables

Sending the PBIX would have saved a lot of time from the start.


@Anonymous wrote:

@Anonymouscan I send you my PBIX, it is very simple file with 2 tables


 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

DateTable.jpgFact.jpg

So here is my fact table and date table, date keys in fact are coming from Date table.

Anonymous
Not applicable

Here is Total Sales

TOTAL_SALES = SUMX(Filter('SALES_TABLE','SALES_TABLE'[COLOR]="Blue"),'SALES_TABLE'([Amt])

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.