Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
AlinaP92
New Member

SAMEPERIODLASTYEAR() sums last quarter instead of showing the previous one

Hello,

 

I'm wondering how to force SAMEPERIODLASTYEAR() not to sum figures from the last available quarter taking into account that the quarter is not complete yet. 

 

The example is below. The function correctly takes figures from January and February 2013, shows them near January and February 2014, but when it comes to the quarter result, instead of seeing figures from Q1 2013 (2,656,502.36) I got a simple sum of January&February 2014 which equals 1,618,669.75. 

 

How to get 2,656,502.36 in the second column instead of 1,618,669.75?

 

Answers to the most typical questions:

 

1. I'm using a table that is marked as Date Table.

2. All connections between tables are established. 

3. There are no dates after the 4th of February in both fact and dimension tables. 

 

AlinaP92_0-1637244525017.png

 

1 ACCEPTED SOLUTION
AlinaP92
New Member

It turned out to be much easier. The date table should contain all dates related to the current year, even if the year hasn't ended yet. Then the calculations are correct.

View solution in original post

3 REPLIES 3
AlinaP92
New Member

It turned out to be much easier. The date table should contain all dates related to the current year, even if the year hasn't ended yet. Then the calculations are correct.

AlinaP92
New Member

Hello @amitchandak 

 

I'm currently using one SAMEPERIODLASTYEAR() formula that is applied to all time periods:

 

SalesSamePeriodLastYear = CALCULATE(SUM(fact_InternetSales[SalesAmount]), SAMEPERIODLASTYEAR(dim_Date[Date]))
 
How do I calculate subtotals separately?
amitchandak
Super User
Super User

@AlinaP92 , You can use last year same qtr in sub total using isinscope

 

If(isinscope(date[Qtr]) && not(isinscope(Date[Month] )) , [Last year Qtr sales], [Sales Sameperiod last year ])

 

example

 

Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,Year)))
Last year same QTR full  Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(ENDOFQUARTER(dateadd('Date'[Date],-1,Year))))

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.