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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Need help with writing DAX

Hi All,

 

Can you please help me write dynamic DAX measure? I have the date and Email address column in a table. I want to find how many emails were sent during a given period and categorize them accordingly. I am using a date in a filter and by changing the date, I can change the category ( i.e. number of emails sent) in that given period. 

 

For instance, in Jan-2020 two email was sent and it will be categorized as 2 emails. And when I change the filter from month to year it gives me an email sent in a year to the customer. 

 

Thank you so much for any given any help!

 

 

 

Date EmailAddressEmail Sent/Year 
10-Jan-20A@com4
20-Jan-20A@com4
21-Jul-20A@Com4
21-Mar-20A@com4
22-Mar-21A@com3
2-Apr-21A@com3
3-Apr-21A@com3
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Maybe:

Email Sent/Year =
  VAR __Year = YEAR(MAX('Table'[Date]))
  VAR __EmailAddress = MAX('Table'[EmailAddress])
  VAR __Table = FILTER(ALL('Table'),YEAR('Table'[Date])=__Year && 'Table'[EmailAddress]=__EmailAddress)
RETURN
  COUNTROWS(__Table)


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...

View solution in original post

2 REPLIES 2
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

The DAX measure doesn't need to be complicated for this:

Emails Sent = COUNTROWS(Table)

You can then construct a visual (eg matrix of email vs year) or combination of visuals (eg date slicer and table with email & Emails Sent) to get the insight.

Greg_Deckler
Community Champion
Community Champion

@Anonymous Maybe:

Email Sent/Year =
  VAR __Year = YEAR(MAX('Table'[Date]))
  VAR __EmailAddress = MAX('Table'[EmailAddress])
  VAR __Table = FILTER(ALL('Table'),YEAR('Table'[Date])=__Year && 'Table'[EmailAddress]=__EmailAddress)
RETURN
  COUNTROWS(__Table)


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...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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