Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
allejot
Frequent Visitor

Min and Max Date between two tables

Hi guys, 

 

I am pretty new to DAX and I need a little help in solving an issue. Here my situation:

 

2 tables:

- PROJECT: project ID

- LEDGER LINES: posting date, project id

 

Desired outcome in table PROJECT: project ID, earlest date, latest date

 

I basically want to create 2 calculated columns in table project showing me earliest and latest activity in the project. Any help with the formulas I need for these 2 columns? Thanks!!

1 ACCEPTED SOLUTION
shreyamukkawar
Resolver II
Resolver II

Hi  @allejot,

As per your question I have created the below table.

 

shreyamukkawar_0-1669974091342.png

 

1. Create a new column as 

Earliest date = CALCULATE(Min('LEDGER LINES'[posting date]),FILTER('LEDGER LINES','LEDGER LINES'[Project Id]=project[Project id]))
2. Create a new column as 
Latest date = CALCULATE(MAX('LEDGER LINES'[posting date]),FILTER('LEDGER LINES','LEDGER LINES'[Project Id]=project[Project id]))
 
Results:

 
shreyamukkawar_2-1669974323780.png

 

Best Regards,
Shreya

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

 

View solution in original post

2 REPLIES 2
_MG_
Frequent Visitor

Hi @allejot,

i would recommend creating a relationship between the two tables.

_MG__0-1669975450993.png

After this you can easily create your columns with the earliest and the latest date.
Therfore create a new column in the Project Table. 

EarliesteDate = MINX(RELATEDTABLE('Ledger Lines'), 'Ledger Lines'[PostingDate])
LatestDate = MAXX(RELATEDTABLE('Ledger Lines'), 'Ledger Lines'[PostingDate])
_MG__1-1669975796217.png

 


In this solution you are using something wichich is called "Row context". It is a very import thing within DAX. 
I hope this will help you.
 
Best Regards 
_MG_

 

 

shreyamukkawar
Resolver II
Resolver II

Hi  @allejot,

As per your question I have created the below table.

 

shreyamukkawar_0-1669974091342.png

 

1. Create a new column as 

Earliest date = CALCULATE(Min('LEDGER LINES'[posting date]),FILTER('LEDGER LINES','LEDGER LINES'[Project Id]=project[Project id]))
2. Create a new column as 
Latest date = CALCULATE(MAX('LEDGER LINES'[posting date]),FILTER('LEDGER LINES','LEDGER LINES'[Project Id]=project[Project id]))
 
Results:

 
shreyamukkawar_2-1669974323780.png

 

Best Regards,
Shreya

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors