Return lowest date across two tables

SJLoxton

New Member
Hello- I am new to Power BI & DAX. I am struggling to work out how to return lowest date across two tables.
I want the following rules applied
If deceased date blank then end date
If deceased date before end date- deceased date
All else end date

Format Looks like Below
Membership Table Member Table Result I want
Member IDEnd Date Member IDDeceased Date Member IDDate
121/01/2020 131/12/2019 131/12/2019
213/05/2000 2 213/05/2000
31/01/2019 3 31/01/2019
431/12/2018 41/05/2019 431/12/2018
55/04/2020 5 55/04/2020

<colgroup><col><col span="2"><col><col span="2"><col><col></colgroup><tbody>
</tbody>
Appreciate your help!
SJ

<colgroup><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Craigc3814

Board Regular
I know how to do it through Power Query to get you up and running but someone will have a better answer through DAX.

Merge your queries on member id and expand the deceased date. Create an if formula in power query to get a new column with your answer.
 

macfuller

Board Regular
Assuming you want the column in the Membership Table...
Code:
[Revised End Date] =VAR DeceaseDate =
    CALCULATE (
        MAX ( 'Member Table'[Deceased Date] ),
        FILTER (
            'Member Table',
            'Member Table'[Member ID] = 'Membership Table'[Member ID]
        )
    )
RETURN
    IF (
        ISBLANK ( DeceaseDate ),
        'Membership Table'[End Date],
        IF (
            'Membership Table'[End Date] - DeceaseDate > 0,
            DeceaseDate,
            'Membership Table'[End Date]
        )
    )
 

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top