Forum Discussion
Compare dates from two different tables
Hello Power BI Champions!!
I am trying to compare two dates from two tables and the relationship between the columns is active.
I wrote the following calculation to get 1 and 0.
Column=
If (Table1[Ticket Close Date]> Related Table2 [End of month],1,0)
but Im not getting 1 as a result? where am i going wrong?
* Also what will be the calculation, if the relationship is not active? Thanks a lot!!
Table - 1 Table-2
| Ticket Close Date | End of month |
| 22/Sept/2020 | 31/08/2020 |
6 Replies
- vanessafvgCommunity Champion
if the relationship is not active, you need to use the userelationship() function to force the measure you want to look at a specific date.
more information here.
https://docs.microsoft.com/en-us/dax/userelationship-function-dax
https://www.youtube.com/watch?v=sONvctPlplY
however looking at your code, what are you joining on relationship wise.- JCK2Helper III
vanessafvg I am not joining anything!
I am trying to find out, which date is greater from the both tables and if its greater give me 1 else 0.
Thanks!
- vanessafvgCommunity Championwhy are you creating a column rather than a measures? ok if there is no relationship between the tables - what is the purpose of what you are doing so i can understand better, what is your objective?
if you are just trying to get the max date from each table
ie.
isgreater =
VAR maxtable1 =
CALCULATE ( MAX ( table1[date] ) )
VAR maxtable2 =
CALCULATE ( MAX ( table2[date] ) )
RETURN
IF ( maxtable1 > maxtable2, 1, 0 )