cancel
Showing results for
Did you mean:
Member

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

I have the following table:

 CodSale Sold Date 1 125 2018-05-10 2 100 2018-05-15 3 150 2018-05-20 4 50 2018-06-20 5 75 2018-06-25

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

 Month SoldLastMonth May 0 Jun 375 (Sum of sales May) Ago 125 (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

Accepted Solutions
Highlighted
Super User

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

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

2 REPLIES 2
Super Contributor

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

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

Proud to be a Datanaut!

Highlighted
Super User

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

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

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 139 members 1,783 guests
Recent signins: