cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
    )
)

1.png

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.

View solution in original post

3 REPLIES 3
Highlighted
Super User I
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. 

 

Might be helpful....

 

image.png





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

Proud to be a Super User!




Highlighted
Microsoft
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
    )
)

1.png

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.

View solution in original post

Highlighted
Super User IV
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
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

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

Community Blog

Community Blog

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

Upcoming Events

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

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