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
Trebor84
Helper II
Helper II

working days of oldest email

Hi,

 

Hoping someone can help me please.

 

I have a table of email received dates and the folder they are currently in, I.e inbox or sent. 

 

I need to find a way to calculate the working days (min-fri) outstanding (also excluding bank holidays) of the oldest email in the inbox folder and display this date in a card visual.

 

I have included a separate table listing all uk bank holidays.


I have also included a basic calendar table, but understand I may need to include the weekday function in the table to be able to accomplish this.

 

I have included a sample file.

working day test.pbix 

 

Thanks

2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

Hi @Trebor84 

One way would be to

1. Add a new column to the code that generates your calendar table to track actual working days:

    "IsWorkingDay",
        IF (
            NOT [Date] IN DISTINCT ( holidays[UK BANK HOLIDAYS] )
                    && NOT WEEKDAY ( [Date], 2 ) IN { 6, 7 },
            "YES",
            "NO"
        )

 2. Create the measure and place it in a card visual:

WorkingDaysOutstanding = 
VAR oldestInboxDate_ = CALCULATE ( MIN ( emails[email sent] ), emails[folder] = "Inbox" )
RETURN
    CALCULATE (
        COUNT ( 'Calendar'[Date] ),
        DATESBETWEEN ( 'Calendar'[Date], oldestInboxDate_, TODAY () ),
        'Calendar'[IsWorkingDay] = "YES"
    ) - 1

 See it all at work in the attached file.

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

v-yiruan-msft
Community Support
Community Support

Hi @Trebor84 ,

I updated your sample pbix file, please find the attachment for the details.

First, you can create a calculated column in calendar table to judge the date is working date or not:

Isworkingday = 
VAR _tab =
    CALCULATETABLE ( VALUES ( 'holidays'[UK BANK HOLIDAYS] ) )
RETURN
    IF ( 'Calendar'[Date] IN _tab || WEEKDAY ( 'Calendar'[Date], 2 ) > 5, 0, 1 )

Then create a measure to get the working days

Working days = 
VAR _oldestdate =
    CALCULATE ( MIN ( 'emails'[email sent] ), 'emails'[folder] = "inbox" )
RETURN
    CALCULATE (
        COUNTROWS ( FILTER ( 'Calendar', 'Calendar'[Isworkingday] = 1 ) ),
        DATESBETWEEN ( 'Calendar'[Date], _oldestdate, TODAY () )
    )

yingyinr_0-1620726253936.png

If the above one is wrong, please provide the correct calculation logic and expected result with examples. Thank you.

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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Trebor84 ,

I updated your sample pbix file, please find the attachment for the details.

First, you can create a calculated column in calendar table to judge the date is working date or not:

Isworkingday = 
VAR _tab =
    CALCULATETABLE ( VALUES ( 'holidays'[UK BANK HOLIDAYS] ) )
RETURN
    IF ( 'Calendar'[Date] IN _tab || WEEKDAY ( 'Calendar'[Date], 2 ) > 5, 0, 1 )

Then create a measure to get the working days

Working days = 
VAR _oldestdate =
    CALCULATE ( MIN ( 'emails'[email sent] ), 'emails'[folder] = "inbox" )
RETURN
    CALCULATE (
        COUNTROWS ( FILTER ( 'Calendar', 'Calendar'[Isworkingday] = 1 ) ),
        DATESBETWEEN ( 'Calendar'[Date], _oldestdate, TODAY () )
    )

yingyinr_0-1620726253936.png

If the above one is wrong, please provide the correct calculation logic and expected result with examples. Thank you.

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.
AlB
Super User
Super User

Hi @Trebor84 

One way would be to

1. Add a new column to the code that generates your calendar table to track actual working days:

    "IsWorkingDay",
        IF (
            NOT [Date] IN DISTINCT ( holidays[UK BANK HOLIDAYS] )
                    && NOT WEEKDAY ( [Date], 2 ) IN { 6, 7 },
            "YES",
            "NO"
        )

 2. Create the measure and place it in a card visual:

WorkingDaysOutstanding = 
VAR oldestInboxDate_ = CALCULATE ( MIN ( emails[email sent] ), emails[folder] = "Inbox" )
RETURN
    CALCULATE (
        COUNT ( 'Calendar'[Date] ),
        DATESBETWEEN ( 'Calendar'[Date], oldestInboxDate_, TODAY () ),
        'Calendar'[IsWorkingDay] = "YES"
    ) - 1

 See it all at work in the attached file.

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

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.