Forum Discussion
DAX Help - Date Comparison between 2 Tables
I've been stuggling with the Dax that will compair all dates per "ID" and provide the max date ("Expected Results"). Can someone provide assistance on the best approach
| Table 1 | Table 2 | |||||||
| ID | DG6 | N3500 | R3450 | ID | Close Date | Expected Result | ||
| 1 | 10/15/2021 | 1 | 10/26/2021 | 10/26/2021 | ||||
| 2 | 11/1/2021 | 2 | 11/1/2021 | |||||
| 3 | 1/10/2022 | 12/10/2021 | 3 | 1/10/2022 | ||||
| 4 | 1/29/2021 | 1/22/2022 | 4 | 3/15/2022 | 3/15/2022 |
Thanks,
Debbie
- Anonymous4 years ago
Hi Anonymous ,
Please create a new measure.
Expected Result = var _id1 = MAX('Table1'[ID]) var _id2 = MAX('Table2'[ID]) var _value_1 = CALCULATE(MAX('Table1'[DG6]),FILTER(ALL(Table1),'Table1'[ID]=_id1)) var _value_2 = CALCULATE(MAX('Table1'[R3450]),FILTER(ALL(Table1),'Table1'[ID]=_id1)) var _value_3 = CALCULATE(MAX('Table1'[N3500]),FILTER(ALL(Table1),'Table1'[ID]=_id1)) var _value_4 = CALCULATE(MAX('Table2'[Close Date]),FILTER(ALL(Table2),'Table2'[ID]=_id2)) return MAX(_value_4,MAX(_value_3,MAX(_value_2,_value_1)))Best Regards,
Community Support Team_GaoIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
4 Replies
- VahidDMSuper User
Hi Anonymous
Can you please split your table 1 and 2 and expected result to make it clear.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/- AnonymousNot applicable
Hopefully this is more helpful. The logic I'm looking for is take the CLOSE_DATE else take the Max date.
Thanks,
Debbie
- AnonymousNot applicable
And I'm using DirectQuery
- AnonymousNot applicable
Hi Anonymous ,
Please create a new measure.
Expected Result = var _id1 = MAX('Table1'[ID]) var _id2 = MAX('Table2'[ID]) var _value_1 = CALCULATE(MAX('Table1'[DG6]),FILTER(ALL(Table1),'Table1'[ID]=_id1)) var _value_2 = CALCULATE(MAX('Table1'[R3450]),FILTER(ALL(Table1),'Table1'[ID]=_id1)) var _value_3 = CALCULATE(MAX('Table1'[N3500]),FILTER(ALL(Table1),'Table1'[ID]=_id1)) var _value_4 = CALCULATE(MAX('Table2'[Close Date]),FILTER(ALL(Table2),'Table2'[ID]=_id2)) return MAX(_value_4,MAX(_value_3,MAX(_value_2,_value_1)))Best Regards,
Community Support Team_GaoIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems with it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data