Forum Discussion
Iterate rows in a table based on multiple columns from another table
- Anonymous2 years ago
Hi Kaavya ,
amustafa's solution is right , but you need to transform Date.1 type to Date . When I used to use the datediff function with a text type, it would display a numeric error.Here are my results:
Below is my table1:
Below is my table2:
The following DAX might work for you:
Status = var lat = FILTER('Table 2','Table 2'[ID.2] = 'Table 1'[ID.1] && 'Table 2'[Type.2] = 'Table 1'[Type.1] && 'Table 2'[Date.2] < 'Table 1'[Date.1]) var A = CALCULATE(MAX('Table 2'[Date.2]),lat) var dis = SELECTEDVALUE('Table 2'[Discharge],A) RETURN IF(ISBLANK(A),"Yes",IF(dis = "True","yes",IF(DATEDIFF(A,'Table 1'[Date.1],DAY) > 7 , "yes","no")))The final output is shown in the following figure:
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Kaavya ,
amustafa's solution is right , but you need to transform Date.1 type to Date . When I used to use the datediff function with a text type, it would display a numeric error.Here are my results:
Below is my table1:
Below is my table2:
The following DAX might work for you:
Status =
var lat = FILTER('Table 2','Table 2'[ID.2] = 'Table 1'[ID.1] && 'Table 2'[Type.2] = 'Table 1'[Type.1] && 'Table 2'[Date.2] < 'Table 1'[Date.1])
var A = CALCULATE(MAX('Table 2'[Date.2]),lat)
var dis = SELECTEDVALUE('Table 2'[Discharge],A)
RETURN
IF(ISBLANK(A),"Yes",IF(dis = "True","yes",IF(DATEDIFF(A,'Table 1'[Date.1],DAY) > 7 , "yes","no")))
The final output is shown in the following figure:
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous Xianda Tag,
thank you so much for your reply.
i will give it a go.
Also is it possible to do this in power query? If so, can you please help with that.
thanks
kaavya