cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
ajsjoshua Regular Visitor
Regular Visitor

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
Community Support Team
Community Support Team

Re: previous month sales

Hi @ajsjoshua

 

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

Re: previous month sales

@ajsjoshua 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 Datanaut !





Community Support Team
Community Support Team

Re: previous month sales

Hi @ajsjoshua

 

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.
Super User
Super User

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.