Forum

Calculating working...
 
Notifications
Clear all

Calculating working days with conditions.

5 Posts
2 Users
0 Reactions
83 Views
(@dcat5066)
Posts: 6
Active Member
Topic starter
 

I have a table that displays customers, samples, sample received date and testing complete date. I need to calculate the number of working days (based on a Monday - Friday workweek) that the samples were in test. The below DAX works great for this.

Days in Test = CALCULATE(COUNT(Dates[Date]),FILTER(ALL(Dates),Dates[Date]>=MIN (Samples[Date Received]) && Dates[Date] <=MIN (Samples[Date Complete]) && WEEKDAY((Dates[Date]),2)<>6 && WEEKDAY((Dates[Date]),2) <>7))

 

And Matrix image is attached as Measure 1: 

However, my condition is that if there is no testing complete date and the samples are still in test then there is a running count of working days. 

Thus,

Days in test w/ cond = CALCULATE(COUNT(Dates[Date]), FILTER(ALL(Dates), Dates[Date] >= MIN(Samples[Date Received]) && Dates[Date] <= IF(ISBLANK(MIN(Samples[Date Complete])), TODAY(),MIN(Samples[Date Complete])) && WEEKDAY((Dates[Date]),2) <> 6 && WEEKDAY((Dates[Date]),2 <> 7 )))
 
This works but matrix shows all samples under each customer, not just their own. Image attached Measure 2.
 
I'm stuck.Measure-1.jpgMeasure-2.jpg 
 
Posted : 07/09/2019 10:32 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Deena,

Can you upload a sample file with test data? It will be much easier to work on a sample than on imaginary data.

You can take a look at this article, to see how you can handle data using variables.

 
Posted : 09/09/2019 1:09 am
(@dcat5066)
Posts: 6
Active Member
Topic starter
 

Attached is a sample file. Thank you.

 

(Attachment removed, contained personal data. CB)

 
Posted : 10/09/2019 10:29 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Deena,

Add 2 columns to Sample table, with the following formula:

Status Desc=RELATED('Status'[Status])

Name=RELATED(Contact[Customer Name])

Use the new fields Status Desc and Name instead of those from the related tables.

 
Posted : 10/09/2019 12:22 pm
(@dcat5066)
Posts: 6
Active Member
Topic starter
 

Perfect, thank you.

 
Posted : 11/09/2019 4:25 pm
Share: