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

PREVIOUSMONTH returns wrong results

I want to sum the number of 'Activations' in the previous month. So if the report was run and viewed any time during say April (the current month), the 'previous month's figures would be for all of March.

 

I have a new measure on my fact table:

 

 

TotalActivationsPreviousMonth = CALCULATE(sum(fact_PatientActivations[TotalActivations]), PREVIOUSMONTH(dim_Date[D_Date]))

 

 

Results are not correct, expecting 101 but I get 57 (highlighted):

image.png

 

 

 

 

 

 

 

Here is the relationship between the date dimension and fact table

 

image.png

 

 

 

 

 

 

And this is the structure of the fact table:

 

image.png

 

I would expect the formula to sum all TotalActivations for the month of March. But it doesn't seem to be doing that. 

 

Am I missing something obvious?

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Would you please use the following measure :

 

TotalActivationsPreviousMonth =

CALCULATE (

    SUM ( fact_PatientActivations[TotalActivations] ),

    ALL ( fact_PatientActivations ),

    PREVIOUSMONTH ( dim_Date[D_Date] )

)

 

If it doesn't meet your requirement, Could you please inform us more detailed information, such as d your sample data(by using OneDrive for Business) if possible? Then we will help you more correctly. Please don't contain any Confidential Information or Real data in your reply or files.

 

 

Best Regards,

Dedmon Dai

amitchandak
Super User
Super User

@Anonymous , your formula seems correct. Just check do you have timestamp in your date.

 

Change the data type to timestamp and view it in format to have time and check. It it has timestamp.

 

Date = [Datetime].date

Date = date(year( [Datetime]),month( [Datetime]),day( [Datetime]))

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.