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

Calculated column first and last entries of different column

Hi,
I need to add a calculated column to a table that is in the tabulr model, I need a flag that checks each job whether the first entry (based on the date) of the value in column 'From Code' is the same as
the last entry of column 'To Code' (based on the date).
I need the outcome looks like below. Job111 to be flage as 'Yes' becaue the value of 'From Code' = MA is the same as the last entry of 'To Code'= MA.

 

2021-03-31_10-09-41.png

Or even a measure, it does not have to be calculated column.

Thanks in advance

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You mean a DAX calculated column, right?

 

Vera_33_0-1617152997761.png

Flag = 
VAR CurJob = 'Table'[Job Number]
VAR T1 = FILTER('Table','Table'[Job Number]=CurJob)
VAR MinDate = MINX(T1,[Created DateTime Local])
VAR MaxDate = MAXX(T1,[Created DateTime Local])
VAR FromCode = MAXX(FILTER(T1,'Table'[Created DateTime Local]=MinDate),[From Code])
VAR ToCode = MAXX(FILTER(T1,'Table'[Created DateTime Local]=MaxDate),[To Code])
RETURN
IF(FromCode=ToCode,"Yes","No")

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Flag = if(LOOKUPVALUE(Data[From Code],Data[Created DateTime Local],CALCULATE(min(Data[Created DateTime Local]),FILTER(Data,Data[Job Number]=EARLIER(Data[Job Number]))),Data[Job Number],Data[Job Number])=LOOKUPVALUE(Data[To Code],Data[Created DateTime Local],CALCULATE(max(Data[Created DateTime Local]),FILTER(Data,Data[Job Number]=EARLIER(Data[Job Number]))),Data[Job Number],Data[Job Number]),"Yes","No")

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You mean a DAX calculated column, right?

 

Vera_33_0-1617152997761.png

Flag = 
VAR CurJob = 'Table'[Job Number]
VAR T1 = FILTER('Table','Table'[Job Number]=CurJob)
VAR MinDate = MINX(T1,[Created DateTime Local])
VAR MaxDate = MAXX(T1,[Created DateTime Local])
VAR FromCode = MAXX(FILTER(T1,'Table'[Created DateTime Local]=MinDate),[From Code])
VAR ToCode = MAXX(FILTER(T1,'Table'[Created DateTime Local]=MaxDate),[To Code])
RETURN
IF(FromCode=ToCode,"Yes","No")
Anonymous
Not applicable

Brriliant, Thanks @Vera_33 , it worked.

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