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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
calliandutra
Frequent Visitor

Differences with SAMEPERIODLASTYEAR and Dates

Hi,

I have a doubt with DAX formula SAMEPERIOLASTYEAR.

To explain, I will use a real example. (I'm a Brazilian, so my screenshots are in Portuguese, but it's easy to understand)

 

I have a dimension table "Calendar" and a fact table "Sales". The sales date is linked with date Calendar.

 

There's two formulas

$ Sales = SUM(fCtrc[VL_TOTAL])
$ Sales Last Year = CALCULATE( SUM(fCtrc[VL_TOTAL]); SAMEPERIODLASTYEAR( dCalendar[Date] ) )

 

Here the things are perfect. All DAX are working correctly.


My problem is:

In my example, "today" is 2017-03-03.

In Last Year the sales during all March (2016) was $8.079,656,38.
Between 2016-03-01 and 2016-03-03 (three days) was $ 888.203,72

 

When I put the fields in a table (Year; Sales; Sales Last Year), instead March 2017 consider just March 2016 until 2016-03-03, the formula consider all March 2016 month.

 

But, if I put a filter considering until Yesterday (2017-03-02), the formula consider correctly.

 

I was clear? If it's confuse I can try explain better.

 

Thanks

 

.WrongWrongCorrectlyCorrectly

1 REPLY 1
Anonymous
Not applicable

Hi @calliandutra,

Do you create measures in your sceanrio? If that is the case, how about  creating a calculated column using the following formula?

sales last year = CALCULATE([$ Sales]; SAMEPERIODLASTYEAR(dCalendar[Date]))

When I use data slicer to filter sales last year column,everything works as expected.

Thanks,
Lydia Zhang

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors