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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Get First and Last Date from Group

I have imported an Outlook Mail box and I want to flag the first and last email in a conversation.

I have started by normalising the subject by removing FW: and RE: so I can group the emails by subject.

 

I'm struggeling with the DAX to identify the first and last date in each group through.

 

I am currently trying the following:

StartDate = CALCULATE(MIN(Mail[DateTimeReceived]),filter(mail,Mail[Subject]))
 
But getting the error Cannot convert value from tect to Yes/No and I think thats my filter.
If I take the Filter out it complains about a circular dependency on mail[Startdate]
 
Any help would be appreciated.
 
Thanks.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Just incase anyone googles this in the future and needs the answer - here you go:

 

Earliest = Calculate(min(Mail[DateTimeReceived]),filter(mail,Mail[subject]=earliest(Mail[Subject])))

And

Latest = Calculate(max(Mail[DateTimeReceived]),filter(mail,Mail[subject]=earliest(Mail[Subject])))

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

As for the error:  Cannot convert value from text to Yes/No; 

You have to actually filter something. FILTER(TABLE,EXPRESSION) 

 

Table = mail <-- your table 

Expression = Mail[Subject] <-- your column

 

You might want to filter a specific subject text, i.e. FILTER(mail,Mail[Subject]="Subjectname")


Anonymous
Not applicable

The better question here might be then - How do you replicate a SQL GroupBY clause in DAX

Anonymous
Not applicable

I am now trying the following moving away from the Filter

StartDate = CALCULATE(MIN(Mail[DateTimeReceived]),Groupby(Mail,Mail[Subject]))
 
But now I get a circular dependency on mail[startdate]....
Anonymous
Not applicable

Just incase anyone googles this in the future and needs the answer - here you go:

 

Earliest = Calculate(min(Mail[DateTimeReceived]),filter(mail,Mail[subject]=earliest(Mail[Subject])))

And

Latest = Calculate(max(Mail[DateTimeReceived]),filter(mail,Mail[subject]=earliest(Mail[Subject])))

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors