The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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 | EmailAddress | Email Sent/Year |
10-Jan-20 | A@com | 4 |
20-Jan-20 | A@com | 4 |
21-Jul-20 | A@Com | 4 |
21-Mar-20 | A@com | 4 |
22-Mar-21 | A@com | 3 |
2-Apr-21 | A@com | 3 |
3-Apr-21 | A@com | 3 |
Solved! Go to Solution.
@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)
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.
@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)
User | Count |
---|---|
26 | |
10 | |
8 | |
6 | |
6 |
User | Count |
---|---|
31 | |
11 | |
10 | |
10 | |
9 |