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
Anonymous
Not applicable

Excluding weekend days from formula

Hi all, 
 
i'm trying to create a measure which shows me the % illness in a month/year, etc. I created the following measure which shows me the days that resources have been ill (based on start and end date of the notification). Underlying measure shows me the days ill per resource in a specific period incl. weekend days. 
# Days ill = sumx(values(Resource[ID]), SUMX(VALUES('Dimdate'[Date]), [# Ill]*[# FTE]))
 
But unfortenately I would like to know the days will excluding weekend days. I do have a column in the dimdate table which shows me true or false for "IsWeekend. "But i dont know how to add that in the formula above. 
 
Hopefully Somebody can help me? 🙂 Thanks in advance!
 
1 ACCEPTED SOLUTION

Hi @Anonymous ,

You can create a calculated column as below in the table 'resource' to get the number of working days:

# Days ill =
CALCULATE (
    COUNTROWS ( 'DimDatum' ),
    FILTER ( 'DimDatum', 'DimDatum'[Is_Weekend] = "false" ),
    DATESBETWEEN ( 'DimDatum'[Date], 'resource'[Start Date], 'resource'[End Date] )
)

If the above one can't help you get the desired result, please provide some raw data in your table 'resource' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Gav10
Helper II
Helper II

Hi @Anonymous 

 

Keen to know if you managed to solve this??

 

I have a similar issue where i'm calculating sickness absence per month based on start/end dates which span months. I've got a nice measure which works out the days someone is absent in each month, but it includes weekends and i can't work out how to exclude them!!

 

Like you i've also created a weekend true/false in my date table but can't work out how to filter against it using the sumx

 

Nightmare!

shreyamukkawar
Resolver II
Resolver II

Try using this.

Sumx(filter(dimdate, 'dimdate'[isweekend] = "false");VALUES('Dimdate'[Date]))

Anonymous
Not applicable

Tried that as well, but gives me an error as well 

# Days ill =
sumx(values(resource[ID]), Sumx(filter(dimdatum, 'DimDatum'[Is_Weekend] = "false"),VALUES('DimDatum'[Datum]) , [# Ill]*[# FTE]))
 
Error is too many arguments were passed to the sumx function. Maximum argument count for function is 2. 

Hi @Anonymous ,

You can create a calculated column as below in the table 'resource' to get the number of working days:

# Days ill =
CALCULATE (
    COUNTROWS ( 'DimDatum' ),
    FILTER ( 'DimDatum', 'DimDatum'[Is_Weekend] = "false" ),
    DATESBETWEEN ( 'DimDatum'[Date], 'resource'[Start Date], 'resource'[End Date] )
)

If the above one can't help you get the desired result, please provide some raw data in your table 'resource' (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
shreyamukkawar
Resolver II
Resolver II

Hi @Anonymous 

 

Try by using NETWORKDAYS dax.

It will help you to exclude weekend between two dates.

NETWORKDAYS ( DATE ( 2022, 5, 28 ), DATE ( 2022, 5, 30 ), 1 )

 

Best Regards 

Shreya

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 

 

Anonymous
Not applicable

Hi Shreyamukkawar, 

 

I do have a column in my dimdate that shows me whether a day is a weekend day or a weekday, so thats not the problem. The problem is to add this value as a filltervalue in this part of the formula: SUMX(VALUES('Dimdate'[Date])

So i need to add something like ,filter(dimdate, 'dimdate'[isweekend] = "false"), but unfortenately thats not working. 

 

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.

Top Solution Authors