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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
san_jois
Resolver I
Resolver I

Calculate SUM of dax measure

Hi,

I have a data table named 'Dailydata' with one column as 'Quantity'

 

For use of Time intelligence functions, I have created a reference table 'dCalender' and connected it with 'Date' in 'Dailydata' table

 

I have used this to create following measures:

Total Sales=sum(Dailydata(Quantity))

 

Total Sales LY=Caluclate (Sum (Dailydata [Quantity], SAMEPERIODLASTYEAR (dCcalender[date]))

 

I have a date Slicer

 

The error:

i) When I select a date range in the slicer, I get incorrect total in Total Sales LY.

 

ii) Also if I select 29 Feb 2016 as a single date, I still get value for Total Sales LY representing that for 28 Feb 15

 

To work around for error (i), I changed the formula for Total Sales LY as:

Total sales LY Sumx = sumx(dCalender,CALCULATE(sum(Dailydata[Quantity]),SAMEPERIODLASTYEAR(dCalender[Date])))

It is giving correct result now.

 

However, error (ii) still persists..

 

My Question: Is there an error in my approach of comparing sales using time intelligence function? What is the best method to get the correct comparison then? Pls suggest..

 

Thanks.

1 ACCEPTED SOLUTION

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

Well, Feb 29th didn't exist in 15 so that's why you are getting the 28th I would expect.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for replying..

That's what is the question..I mean that if 29th didn't exist in 2015, then the value it should project shoul be (Blank) and not that for a date previous..

Hope it clarifies..

 

Only thing I could think of would be to wrap your calculation in an IF statement that checks the date(s) coming in and if it is something wonky to return BLANK(), otherwise, do the calculation. Seems like you would only ever have a single case where this would happen, Feb 29th. 

 

http://dataap.org/blog/2017/04/30/dax-leap-year-in-power-bi/

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Ok..thanks..

 

Hi @san_jois,

Have you resolved your issue? The solution  @Greg_Deckler posted is right. If you have, please mark the right or helpful reply as answer. So more people will benefit from here.

Best Regards,
Angelia

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.