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
ianneg77
Frequent Visitor

Attempting to get Net days between 2 dates without weekends

I am attempting to calculate the number of work days in between my order date and invoice date. I have 2 main tables, one, a calendar table I created in Excel and uploaded to Power BI, named "Calendar - Excel" (it goes along with my June-July fiscal yr.) and two, a table of order info, named "Aftermarket Analysis".

 

  • I created a calculated column in the my calendar table to flag workdays:

IsWorkDay = SWITCH(WEEKDAY('Calendar - Excel'[DATE],2),6,0,7,0,1)

 

  • I then created another calculated column in my calendar table to do the solution:

Netdays = CALCULATE(SUM('Calendar - Excel'[IsWorkDay]),
DATESBETWEEN('Calendar - Excel'[DATE],'AfterMarket Analysis'[ORDER DATE],'AfterMarket Analysis'[INVOICE DATE]))

 

I then get the following error message:

 

A single value for column 'ORDER DATE' in table 'AfterMarket Analysis' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

What am I missing?

 

I do have a "many to 1" relationship from the Aftermarket table to the Calendar table. The common field is invoice DATE & DATE respectively.

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @ianneg77,

 

You can try to use below calculate column to get available workday count from specific date columns.

WorkDays =
COUNTROWS (
    FILTER (
        CALENDAR (
            'AfterMarket Analysis'[ORDER DATE],
            'AfterMarket Analysis'[INVOICE DATE]
        ),
        WEEKDAY ( [Date], 2 ) < 6
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @ianneg77,

 

You can try to use below calculate column to get available workday count from specific date columns.

WorkDays =
COUNTROWS (
    FILTER (
        CALENDAR (
            'AfterMarket Analysis'[ORDER DATE],
            'AfterMarket Analysis'[INVOICE DATE]
        ),
        WEEKDAY ( [Date], 2 ) < 6
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
CoreyP
Solution Sage
Solution Sage

I feel your pain, @ianneg77!

 

I recently struggled with a similar issue regarding order fulfillment analysis. Unlike you, I had just ONE date and I needed to add either 1 or 3 working days (non weekend, non holiday) depending on the order type, to get a required ship by date.

 

It was a nightmare! But, fortunately, the people of these forums are the smartest, bi, gurus you'll ever meet.

 

Anyway, while I was scouring the internet for a solution to my problem, I found a lot of results for calculating working days between 2 dates. Check out this thread: https://community.powerbi.com/t5/Desktop/NETWORKDAYS-type-function-in-PowerBI/td-p/154902

 

 

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.