cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Frequent Visitor

## Return Earliest Year

HI Experts,

I am trying to have powerBI return the third column below:

It has to filter Project column, find all projects with the same name, and then return a yes for the earliest year.

 Project Delivery Year Earliest Year X 2018 Yes Y 2019 No Y 2018 Yes A 2016 Yes B 2020 Yes C 2018 No C 2017 Yes C 2019 No X 2019 No

Thank you

1 ACCEPTED SOLUTION
Community Support

Hi @PowerBI87  ,

You can also try using the allexcept function to calculate the minimum year for each project and compare it with the year of the current line.Try this measure:

``````Measure =
VAR min_year =
CALCULATE (
MIN ( 'Table'[Delivery Year] ),
ALLEXCEPT ( 'Table', 'Table'[Project] )
)
RETURN
IF ( MAX ( 'Table'[Delivery Year] ) = min_year, "Yes", "No" )``````

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 REPLIES 6
Super User

Hi,

Try this calculated column formula

=IF(Data[Delivery Year]=CALCULATE(Min(Data[Delivery Year]),Filter(Data,Data[Project]=Earlier(Data[Project]))),"Yes","No")

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Frequent Visitor

Is there an if statement that can display a "yes" in the specific row that is the first year?

Community Support

Hi @PowerBI87  ,

You can also try using the allexcept function to calculate the minimum year for each project and compare it with the year of the current line.Try this measure:

``````Measure =
VAR min_year =
CALCULATE (
MIN ( 'Table'[Delivery Year] ),
ALLEXCEPT ( 'Table', 'Table'[Project] )
)
RETURN
IF ( MAX ( 'Table'[Delivery Year] ) = min_year, "Yes", "No" )``````

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Frequent Visitor

Thank you Liang, this works.

Super User

https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Frequent Visitor

Thanks for your reply. I am looking to return the minumum year, not the project with that has the minum year.

Announcements

#### Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors