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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX to Filter by current month

Hello Data Enthusiasts,
I am trying to automate a measure. Actually, it's a filter part of the measure. 

Currently, I am using:

FILTER('Calendar','Calendar'[FinMnthYr]= "Nov-22"))
to filter the data for November month only.
But I want to make it automatic. So that measure filters the data for every current month.
 
Kindly help.
 
Regards,
AJP
1 ACCEPTED SOLUTION
katika555
Resolver I
Resolver I

Hello AJP-PBI
you can use next construction:

 

Calculate (Sum('Table'[Col Electricity]),FILTER('Table',MONTH('Table'[date])=MONTH(now())))

 

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hello @katika555 
Thanks a lot for the solution. It worked.

katika555
Resolver I
Resolver I

Hello AJP-PBI
you can use next construction:

 

Calculate (Sum('Table'[Col Electricity]),FILTER('Table',MONTH('Table'[date])=MONTH(now())))

 

 

I've been reading support forums for several hours, yesterday and today, looking for a solution to why my date filter wasn't working inside a measure. This is the first suggestion that I've come across that is using (now()) instead of (TODAY()).  I tried it on my measure and it worked. I've been stuck for so long on this - thank you!!!!!!

how to add year as well e.g. From date i dont know year as there are dates in the data for multiple year, above expression will not filter correctly if there are multiple dates i.e. multiple years

Hi,  
If you want current Year current month just add additional filter options:

Calculate (Sum('Table'[Col Electricity]),FILTER('Table',MONTH('Table'[date])=MONTH(now())&&Year('Table'[date])=Year(now())))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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