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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
iLikeAzureSQL
Helper I
Helper I

LastYear Sales same period not calculated properly

I need to have the sales for last year same period ( like 01/01/2015 to 06/10/2015) copmpared to this years to date sale

 

I'm using this DAX:

LY YTD Sales = CALCULATE([LY Sales],SAMEPERIODLASTYEAR(DateDimension[Date]))

LY Sales = CALCULATE([Total Sale], SAMEPERIODLASTYEAR(DateDimension[Date]))

Total Sale = SUMX(OrderArchive,OrderArchive[Total])

 

But what it returns it the toal sales for all years before ( my data contains from 2010) and not only 2015!

 

I tried DATEADD(xxx,-1,year) but still hetting same reults. what am I doing wrong ?

 

This is the data where comparing sales for each month per year

1.jpg

 

here is the reults of DAX as I mentioned above

2.jpg

 

Thanks in advance for looking this up

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@iLikeAzureSQL these functions need context to work properly like in a table/matrix with a YEAR field

 

This is obviously not present in a Card!

 

So for a Card use something like this instead...

LY Sales =
CALCULATE (
    [Total Sale],
    FILTER ( 'Calendar', 'Calendar'[Year] = MAX ( 'Calendar'[Year] ) - 1 )
)

 

View solution in original post

2 REPLIES 2
Baskar
Resident Rockstar
Resident Rockstar

Hi 

 

I suggest u y not go withparallelperiod

 

Measure = calculate(sum(sales),parallelperiod(Date,-1,Year)

 

try this....

Sean
Community Champion
Community Champion

@iLikeAzureSQL these functions need context to work properly like in a table/matrix with a YEAR field

 

This is obviously not present in a Card!

 

So for a Card use something like this instead...

LY Sales =
CALCULATE (
    [Total Sale],
    FILTER ( 'Calendar', 'Calendar'[Year] = MAX ( 'Calendar'[Year] ) - 1 )
)

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.