Reply
Regular Visitor
Posts: 26
Registered: ‎06-08-2018
Accepted Solution

How to select previous month and use it to calculate the sales of last month

I have the following table:

CodSaleSoldDate
11252018-05-10
21002018-05-15
31502018-05-20
4502018-06-20
5752018-06-25


I need to make a measure that returns me the following table:

MonthSoldLastMonth
May0
Jun375 (Sum of sales May)
Ago125 (Sum of sales Jun)

 

I tried to use PREVIOUSMONTH and EDATE(Date; -1) but doesn't work.
I will use this measure on a graph to see "Month Over Month".


Accepted Solutions
Highlighted
AlB Super Contributor
Super Contributor
Posts: 1,166
Registered: ‎11-12-2018

Re: How to select previous month and use it to calculate the sales of last month

Hi @gluizqueiroz

 

Have you got a Date table? Time intelligence functions are only guaranteed to work if you have a "complete" Date table.

If you don't, create one, place Month in rows of a matrix visual and this measure in values for the previous month sales:

 

SoldPreviousMonth =
CALCULATE ( SUM ( CodSales[Sold] ); PREVIOUSMONTH ( CalendarTable[Date] ) )

 

View solution in original post


All Replies
Super User
Posts: 746
Registered: ‎09-16-2018

Re: How to select previous month and use it to calculate the sales of last month

hi @gluizqueiroz

 

in order to be able to use TIME INTELLIGENCE functions, you need to create a date dimension and link it to the fact tables:

 

http://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-3-public-holidays

 

 



Did I answer your question? Mark my post as a solution!


Proud to be a Datanaut!

Highlighted
AlB Super Contributor
Super Contributor
Posts: 1,166
Registered: ‎11-12-2018

Re: How to select previous month and use it to calculate the sales of last month

Hi @gluizqueiroz

 

Have you got a Date table? Time intelligence functions are only guaranteed to work if you have a "complete" Date table.

If you don't, create one, place Month in rows of a matrix visual and this measure in values for the previous month sales:

 

SoldPreviousMonth =
CALCULATE ( SUM ( CodSales[Sold] ); PREVIOUSMONTH ( CalendarTable[Date] ) )