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
gluizqueiroz
Resolver I
Resolver I

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".

1 ACCEPTED SOLUTION

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

2 REPLIES 2
LivioLanzo
Solution Sage
Solution Sage

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 correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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] ) )

 

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.