Forum Discussion
DATEDIFF with a condition
- 8 years ago
Hi android1,
Suppose there existing a relationship between 'vw_PivotVisitsInvoiced' and 'CarersList' based on employee ID. If so, you can use below formula to add the DateLeft into 'vw_PivotVisitsInvoiced'.
CarerLastDate = RELATED(CarersList[DateLeft])
Then, create the following calculated column:
Weeks of Employment= IF([CarerLastDate]=BLANK(), DATEDIFF(vw_PivotVisitsInvoiced[Carer_StartDate],TODAY(),WEEK), DATEDIFF( FIRSTDATE(vw_PivotVisitsInvoiced[Carer_StartDate]), LASTDATE(CarersList[DateLeft]) , WEEK ))
Best regards,
Yuliana Gu
Hi android1,
Suppose there existing a relationship between 'vw_PivotVisitsInvoiced' and 'CarersList' based on employee ID. If so, you can use below formula to add the DateLeft into 'vw_PivotVisitsInvoiced'.
CarerLastDate = RELATED(CarersList[DateLeft])
Then, create the following calculated column:
Weeks of Employment= IF([CarerLastDate]=BLANK(), DATEDIFF(vw_PivotVisitsInvoiced[Carer_StartDate],TODAY(),WEEK), DATEDIFF( FIRSTDATE(vw_PivotVisitsInvoiced[Carer_StartDate]), LASTDATE(CarersList[DateLeft]) , WEEK ))
Best regards,
Yuliana Gu
- android18 years ago
Post Patron
v-yulgu-msft A big thanks for this. Does exactly what I needed.
Can't thank you enough.
- nickchobotar8 years ago
Skilled Sharer
The answer to your question was alread presented here:
https://community.powerbi.com/t5/Desktop/Count-Number-of-Weeks-with-a-condition/m-p/377017#M171322
Please try to avoid problem duplication in the future.
Nick -