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! Learn more

Reply
Anonymous
Not applicable

DAX Formula for Assign Date

Hi,

 

I would like to retrieve the assign date by following the below conditions:

1)  for the first month of the record, to retrieve as assign date - the first occurrence/date of the record in that month

2)  starting with the second month, if the record had appeared in the previous month at least one time AND if it IS present in the first day of the second month, to retrieve as assign date - the first occurrence/date of the record in that month

OR

2) starting with the second month, if the record had appeared in the previous month at least one time AND if was NOT present in the first day of the second month, to retrieve as assign date for the second month - the first occurrence/date of the record in the second month

This process is being repeated for all months, by having in mind the first day of the month.

I have the below sample, with the AssignDate that needs to be retrieved.

 

If anything, please let me know.

Many thanks,

Melisa

 

recordMonthDateAssignDate
1244333March3/5/20203/5/2020
1244333March3/15/20203/5/2020
1244333March3/25/20203/5/2020
1244333April4/1/20203/5/2020
1244333April4/5/20203/5/2020
1344222March3/3/20203/3/2020
1344222March3/9/20203/3/2020
1344222April4/5/20204/5/2020
1344222May5/1/20204/5/2020

 

 

1 ACCEPTED SOLUTION

Attached below is the PBIX if it helps.



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

6 REPLIES 6
Anonymous
Not applicable

Hi,

check out this support article from Microsoft, it can lead you somewhere near a solution.

https://docs.microsoft.com/en-us/dax/date-and-time-functions-dax

 

Regards,

Lewis

Create this column:

MonthNum = MONTH([Date])

and then this column:

AssignDate =
VAR __FirstMonth = MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record])),[MonthNum])
VAR __FirstDate = MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record]) && [MonthNum] = __FirstMonth),[Date])
VAR __CurrentMonthDate = MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record]) && 'Data'[MonthNum] = EARLIER('Data'[MonthNum])),'Data'[Date])
VAR __WhoseOnFirst = IF(__CurrentMonthDate = DATE(YEAR(__CurrentMonthDate),MONTH(__CurrentMonthDate),1),TRUE(),FALSE())
RETURN
SWITCH(TRUE(),
[MonthNum] = __FirstMonth,__FirstDate,
__WhoseOnFirst && __FirstMonth = [MonthNum] - 1,__FirstDate,
MINX(FILTER('Data','Data'[record] = EARLIER('Data'[record]) && [MonthNum] <> __FirstMonth),[Date])
)



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

Attached below is the PBIX if it helps.



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

Sorry, trying to paste that into the code windows was giving me some kind of wonky error.


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...
Greg_Deckler
Community Champion
Community Champion

So is your example data provided below minus the AssignDate column and the AssignDate is what you want as the output?



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...
Anonymous
Not applicable

@Greg_Deckler 

 

Yes, the last column is in fact the Output column.

 

Thank you,

Melisa

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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