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
AK1992
Helper I
Helper I

Sum of last 3 months

I've searched on the forum to calculate the sum of last 3 months, but it seems that it does not work for me.

I would like to have the sum of Sep to Nov in December row.

Could you please help to see where is the problem from ?

 

Thank you.

 

image.png

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @AK1992 ,
 
First ,if you don't have a unrelated calendar table, you need to create a new calendar table and use the date as a slicer.
Then create a measure to calculate sales:
sum_Sales_last_3_months =
CALCULATE (
    SUM( Sales[Sales] ),
    FILTER (
        ALL ( Sales[Date] ),
        Sales[Date] <= MAX ( DimDate[Date] )
            && Sales[Date] >= EDATE ( MAX(DimDate[Date]),-3 )
    )
)
 
You can also refer to the pbix.
If the problem persists,could you please share sample data or sample pbix?(Please mask any sensitive data before uploading)
 
Best Regards,
Liang
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
V-lianl-msft
Community Support
Community Support

Hi @AK1992 ,
 
First ,if you don't have a unrelated calendar table, you need to create a new calendar table and use the date as a slicer.
Then create a measure to calculate sales:
sum_Sales_last_3_months =
CALCULATE (
    SUM( Sales[Sales] ),
    FILTER (
        ALL ( Sales[Date] ),
        Sales[Date] <= MAX ( DimDate[Date] )
            && Sales[Date] >= EDATE ( MAX(DimDate[Date]),-3 )
    )
)
 
You can also refer to the pbix.
If the problem persists,could you please share sample data or sample pbix?(Please mask any sensitive data before uploading)
 
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @V-lianl-msft ,

 

Thank you for the reply. It works when i unrelate my calendar table.

But is there other way not to unrelating and still able to calculat the last 3 months ?

Because I need to relate the calendar in the matrix.

 

Thanks,

 

Amy

Hi @AK1992 ,
 
Measure has associated the unrelated calendar table with your existing date. You can use slicer to get the desired result. You can refer to the pbix file I published earlier.
 
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.