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

Calculate orders from next day, exclude weekends

Hi,

 

I am trying to count the amount of shipments I have for the next day. Formula I used did work, but when it is Friday it calculates orders for saturday instead of Monday which is obvious as I added a TODAY()+1 in my measure. When Friday it should be +3 and when it is Saturday it should be +2.

 

My Date table:

Sofien1234_0-1652855065404.jpeg

 

 

My Measure:

 

_Workload Today =

CALCULATE(

Distinctcount(G002_KDE_BI_Report[Shipment No.]),

'G002_KDE_BI_Report'[Pick up date/time] = TODAY(),

'G002_KDE_BI_Report'[_Bin] IN {"Consolidation" , "Consolidated" , "Slot booking" , "Manifest"})

 

For workload next day as said it must calculate 3 days if today is Friday, 2 days if today is Saturday. @amitchandak maybe? I used your date table from Week Not so Weak Blog.

 

Kind Regards,

 

Sofien

4 REPLIES 4
Anonymous
Not applicable

Hi @v-zhangti

 

Did create the file with sensitive data for this visual and measure deleted. Need to look for a solution though as my company blocks filehosting websites and I am not able to upload a PBIX file here apparently as an attachment to my reply. If not able to upload PBIX file here, I will do it later today from my private laptop.

 

Kind Regards,

 

Sofiën

 

 

v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Measure:

Workload next day = 
IF (
    WEEKDAY ( TODAY (), 2 ) = 5,
    CALCULATE (
        DISTINCTCOUNT ( G002_KDE_BI_Report[Shipment No] ),
        FILTER (
            ALL ( 'G002_KDE_BI_Report'[Pick up date] ),
            [Pick up date] >= TODAY ()
                && [Pick up date]
                    <= TODAY () + 3
        )
    ),
    IF (
        WEEKDAY ( TODAY (), 2 ) = 6,
        CALCULATE (
            DISTINCTCOUNT ( G002_KDE_BI_Report[Shipment No] ),
            FILTER (
                ALL ( 'G002_KDE_BI_Report'[Pick up date] ),
                [Pick up date] >= TODAY ()
                    && [Pick up date]
                        <= TODAY () + 2
            )
        ),
        IF (
            WEEKDAY ( TODAY (), 2 ) = 7,
            CALCULATE (
                DISTINCTCOUNT ( G002_KDE_BI_Report[Shipment No] ),
                FILTER (
                    ALL ( 'G002_KDE_BI_Report'[Pick up date] ),
                    [Pick up date] >= TODAY ()
                        && [Pick up date]
                            <= TODAY () + 1
                )
            ),
            CALCULATE (
                DISTINCTCOUNT ( G002_KDE_BI_Report[Shipment No] ),
                FILTER ( ALL ( 'G002_KDE_BI_Report'[Pick up date] ), [Pick up date] = TODAY () )
            )
        )
    )
)

As an example, I hope you can understand this formula better. Suppose today is Friday, May 20.

Date = CALENDAR(MIN(G002_KDE_BI_Report[Pick up date]),DATE(2022,5,20))
Measure Test = 
IF (
    WEEKDAY ( DATE ( 2022, 5, 20 ), 2 ) = 5,
    CALCULATE (
        DISTINCTCOUNT ( G002_KDE_BI_Report[Shipment No] ),
        FILTER (
            ALL ( 'G002_KDE_BI_Report'[Pick up date] ),
            [Pick up date] >= DATE ( 2022, 5, 20 )
                && [Pick up date]
                    <= DATE ( 2022, 5, 20 ) + 3
        )
    )
)

vzhangti_0-1653287767748.png   vzhangti_1-1653287781722.png

Please check if this is the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Anonymous
Not applicable

Hi @v-zhangti,

 

Thanks for helping out, measure works as well, but it was not exactly what I was looking for. I added the pick up date and time column to the matrix table. And on the right filter pane, I want to show only values from today + the next day, this works fine until it's Friday. Then it should take Monday into account as next day instead of Saturday.

 

This is the current measure I have : 

 

_Workload = CALCULATE(Distinctcount(G002_KDE_BI_Report[Shipment No.]))
 
I added the PickUp_date and PickUp_Time column to the rows from the Matrix table. Currently it is displayed as:
 
Sofien1234_0-1653290845417.png

Output is fine because today is Monday and it shows data from today + Tuesday. Filter I added on this visual = 

 

Sofien1234_1-1653290919040.png

 

This filter must calculate next 2 days include today and not take weekends into account.

 

Kind Regards,

 

Sofiën

Hi, @Anonymous 

 

Is it possible to share your PBIX files? Please remove sensitive information in advance. What kind of results do you expect after applying the filter?

 

Best Regards

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.