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
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
v-cherch-msft
Employee
Employee

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

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/
v-cherch-msft
Employee
Employee

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.
PattemManohar
Community Champion
Community Champion

@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 PBI Community Champion




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.