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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
stxreporting
Frequent Visitor

Time intelligence not returning correct value

Hi,

 

I'm using a dateadd function that calculates the previous period's value using a separate date table.

 

It was brought to my attention by a user that the values for 2020 are not correct. I figured out its because I'm using the following expression which doesn't work with leap years:

 

Calculate([some measure],DATEADD('Date'[Date],-365,DAY))

 

This works perfectly except when it's a leap year. 

 

In order to fix this I tried the following:

 

Calculate([some measure],DATEADD('Date'[Date],-1,YEAR))

 

For some reason it is includes the values for the whole month of August last year instead of only taking into account the 9 days that we have so far this month. The date table I'm using is continuous (no gaps) and includes all the dates.

 

Could someone please explain what I am doing wrong?

 

Many thanks,

 

Chris 

4 REPLIES 4
amitchandak
Super User
Super User

@stxreporting , That will happen if you use month year in visual, in that case it is getting complete month dates

 

 

Try like

forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, Calculate([some measure],DATEADD('Date'[Date],-1,YEAR)), blank())
//or
//calculate(Calculate([some measure],DATEADD('Date'[Date],-1,YEAR)),filter('Date','Date'[Date]<=_max))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

 

I do not have month year in my visual, just the measures for current year and for passed year (the one I sent above). I don't see how the solution you proposed will return anything other than blank(), since the max('date'[date]') will by definition always be bigger than _max right?

Could you please elaborate?

Thanks,

 

Chris

Hi, @stxreporting 

Please try formula like:

Result=
 Calculate([some measure],DATEADD('Date'[Date],-1,YEAR),'Table'[Monthnumber]<currentYearMaxMonth)

or apply a filter measure to table visual filter pane.

Best Regards,
Community Support Team _ Easonl

Hi @v-easonf-msft,

 

thanks for your reply but this doesn't seem to change anything?

Could you please elaborate what this part of your solution does?

'Table'[Monthnumber]<currentYearMaxMonth

 

how I see it that would still not be able to retrieve the days passed this month so far?

Please let me know,

 

Chris

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors