Forum Discussion
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!!
- Anonymous3 years ago
Hi allejot,
As per your question I have created the below table.
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 asLatest date = CALCULATE(MAX('LEDGER LINES'[posting date]),FILTER('LEDGER LINES','LEDGER LINES'[Project Id]=project[Project id]))Results:Best Regards,
ShreyaAppreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!
2 Replies
- _MG_Frequent Visitor
Hi allejot,
i would recommend creating a relationship between the two tables.
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])
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_ - AnonymousNot applicable
Hi allejot,
As per your question I have created the below table.
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 asLatest date = CALCULATE(MAX('LEDGER LINES'[posting date]),FILTER('LEDGER LINES','LEDGER LINES'[Project Id]=project[Project id]))Results:Best Regards,
ShreyaAppreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!