Forum Discussion
Date difference based on condition
Hello Community,
Can you please provide your suggestion?
I have two tables and they both have one to one relationship.My requirements is that I want to match ID on both table and if ID will match then I want to AVERAGE DAY DIFFERENCE.
I have tried below formula but I am not getting any result.
Calculated Column=
If (table a[id]=table b[id],average(datediff(table a[date],table b[date],day))
Here is my dataset.
Thanks
Table-A | |
ID | Date |
A | 15/06/2020 |
B | 29/04/2020 |
Table-B | |
ID | Date |
A | 15/06/2020 |
C | 21/04/2020 |
D | 27/02/2020 |
Hi tejapowerbi123 ,
You could try below measure and refer to my sample for details
Measure 2 = IF(MIN(TA[ID])=MIN(TB[ID]), DATEDIFF(MIN(TA[DATE]), MIN(TB[DATE]), DAY), BLANK())Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
9 Replies
- parry2k
Super User
tejapowerbi123 not very clear what would be the output, if there are dates in two tables and it is one row and what would be the average, isn't it is just a datediff? why you are using average?
- tejapowerbi123
Helper V
Hi Parry,
Thank you so much for your suggestion.
Please ignore AVERAGE,I am looking for day difference and it is not working.
Do you have any suggestion for me?
Thanks
- parry2k
Super User
tejapowerbi123 try this, assuming you are adding a new column in Table A, if you are adding a new column in Table B then use RELATED function with Table A
Date Difference = If (table a[id]=RELATED(table b[id]),datediff(table a[date],RELATED(table b[date]),day))I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡