cancel
Showing results for
Did you mean:
Highlighted
Anonymous
Not applicable

## previous month sales

Dear all,

I am using this formula to find previous month sales

CMSales = CALCULATE(SUM(Dispatch[InvoiceAmount]),FILTER('Calendar','Calendar'[YearMonthnumber]=max('Calendar'[YearMonthnumber])-1))

but i am not getting the result

when i checked

test = MAX('Calendar'[YearMonthnumber]) i am getting 201803

but for MAX('Calendar'[YearMonthnumber])-1 i am getting 201.80 but i should get 201802

pls correct where i am wrong.

Regards,

Joshua.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft

## Re: previous month sales

Hi @Anonymous

Based on my test, the test measure seems correct. You may check the format for it. You may try to change your CMSales measure as below to get previous month sales.

```CMSales =
CALCULATE (
SUM ( Dispatch[InvoiceAmount] ),
FILTER (
ALL ( 'calendar' ),
'Calendar'[YearMonthnumber]
= MAX ( 'Calendar'[YearMonthnumber] ) - 1
)
)```

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Highlighted
Super User I

## Re: previous month sales

@Anonymous Please make sure your "YearMonthNumber" is in Number format, if not then try using "VALUE" function in your logic or change the datatype of your "YearMonthNumber" field.

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

Proud to be a Super User!

Highlighted
Microsoft

## Re: previous month sales

Hi @Anonymous

Based on my test, the test measure seems correct. You may check the format for it. You may try to change your CMSales measure as below to get previous month sales.

```CMSales =
CALCULATE (
SUM ( Dispatch[InvoiceAmount] ),
FILTER (
ALL ( 'calendar' ),
'Calendar'[YearMonthnumber]
= MAX ( 'Calendar'[YearMonthnumber] ) - 1
)
)```

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Super User IV

## Re: previous month sales

Hi,

If there is a relationship from the Date column of the Dispatch Table to the Date column of the Calendar Table, then this simple mesure should work

=CALCULATE(SUM(Dispatch[InvoiceAmount]),PREVIOUSMONTH('Calendar'[Date]))

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

#### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

#### Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

#### Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors