Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
android1
Post Patron
Post Patron

Count Number of Weeks with a condition

Hi,

 

I'm using the below to give me the number of weeks someone has been employed.

 

Wks of Employment = DATEDIFF(vw_PivotVisitsInvoiced[Carer_StartDate],TODAY(),WEEK)

 

Works great however in another table CarersList there is an end date column [DateLeft].

Those still employed will have no end date. 

 

How do I modify the above to account for those who have an end date?

2 ACCEPTED SOLUTIONS

@android1

 

It appears to be some data quality. Here is another approach:

 

On your vw_PivotVisitsInvoiced table create the following calculated column:  CarerLastDate = RELATED(CarersList[DateLeft])

This will create another column populated with DateLeft values.

 

From here you can write another calc column:

 

DATEDIFF(vw_PivotVisitsInvoiced[Carer_StartDate],PivotVisitsInvoiced[DateLeft] ,WEEK)

 

or for a measure you got to wrap your fields in FIRSTDATE and LASTDATE

 

See if works.

 

N -

View solution in original post

@android1

 

I see.

Something like this ?

 

IF(

     ISBLANK(vw_PivotVisitsInvoiced[DateLeft],

     Wks of Employment,

     Wks of Employment 2

)

View solution in original post

15 REPLIES 15

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.