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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
craigL01
New Member

Using Datediff to find records in this year

 

I have this DAX code

filter(MYTABLE,DATEDIFF(MYTABLE[MYDATEFIELD],today(),YEAR)=0))
 
its only returning records dated this month
 
any ideas
3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

The logic should work, e.g. here is my test:

ValtteriN_0-1707740707694.png

 

How are you using your dax? Consider if some other filter affects the table. Also here is an alternative:

Calendar filtered = FILTER('Calendar',YEAR('Calendar'[Date])=YEAR(TODAY()))

ValtteriN_1-1707740805797.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/








Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




im using it as a measure

heres the full code

AUKNPSCardsIssuedThisYear = CALCULATE(
    count(PROJTABLE[PROJID]),
    Filter(PROJTABLE,PROJTABLE[AUKInstallStatus] = "Installed (full)"),
    filter(PROJTABLE,DATEDIFF(PROJTABLE[MXMPROJESTIMATEDENDDATE],today(),YEAR)=0))

Hi,

I recommend using this kind of measure:

Data:

ValtteriN_0-1707910303124.png

Here let's imagine status A = Installed (full).

The end result should be 2.

Dax:

Measure 15 = CALCULATE(COUNT('Table (23)'[ID]),'Table (23)'[Status]="A",YEAR('Table (23)'[Date])=YEAR(TODAY()))
ValtteriN_1-1707910439396.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.