cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Shem Regular Visitor
Regular Visitor

I am looking to return the next working day as tomorrow in a Power BI column.

I am looking to return the next working day as tomorrow in a Power BI column. I have the formula that works for Monday to Thursday, however, on a Friday it returns Saturday. Instead i would like Monday to be labelled as 'next working day'.

 

Below is the formula:

 

Return day = IF(DateKey[Date]=TODAY()-1,"yesterday",IF(DateKey[Date]=TODAY()+1,"next work day",IF(DateKey[Date]=TODAY(),"today",("notapplicable"))))

 

I am using this to filter my figures on today, next work day and also last work day.

 

Thanks in advance.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jessica_Seiya Established Member
Established Member

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Believe someone else must have a smart way to go.

 

Basically, the following nest IF means to identify if Today is Friday or Saturday, if not, go use the common +1 logic to mark Next Working day; if it is Firday, +3 as the Next Working day, if it is Saturday, + 2 as the Next Workding day.

 

ReturnDay = 
IF (
    FORMAT ( TODAY (), "DDDD" ) <> "Friday"
        && FORMAT ( TODAY (), "DDDD" ) <> "Saturday",
    IF (
        'DateKey'[Date]
            = TODAY () - 1,
        "Yesterday",
        IF (
            'DateKey'[Date] = TODAY (),
            "Today",
            IF ( 'DateKey'[Date] = TODAY () + 1, "Next Work Day", "Notapplicable" )
        )
    ),
    IF (
        FORMAT ( TODAY (), "DDDD" ) = "Friday",
        IF (
            'DateKey'[Date]
                = TODAY () - 1,
            "Yesterday",
            IF (
                'DateKey'[Date] = TODAY (),
                "Today",
                IF ( 'DateKey'[Date] = TODAY () + 3, "Next Work Day", "Notapplicable" )
            )
        ),
        IF (
            FORMAT ( TODAY (), "DDDD" ) = "Saturday",
            IF (
                'DateKey'[Date]
                    = TODAY () - 1,
                "Yesterday",
                IF (
                    'DateKey'[Date] = TODAY (),
                    "Today",
                    IF ( 'DateKey'[Date] = TODAY () + 2, "Next Work Day", "Notapplicable" )
                )
            )
        )
    )
)

2018-06-29_10-28-01.png

 

View solution in original post

Super User
Super User

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Hi there

 

Here is the way I would do it with Variables and the SWITCH Statement

T/Y/Tom = 
VAR TodaysDate =
    TODAY ()
VAR YesterdayDate =
    TODAY () - 1
VAR NextMondaysDate =
    SWITCH(TRUE(),
        'Date'[Date] - WEEKDAY('DateKey'[Date],2)+1 >= TodaysDate, 'DateKey'[Date] - WEEKDAY('DateKey'[Date],2)+1,
        TODAY()-9
    )
VAR NextWorkingDay =
    SWITCH (
        TRUE (),
        'DateKey'[Date] = TodaysDate, "Today",
        'DateKey'[Date] = YesterdayDate, "Yesterday",
        'DateKey'[Date] = NextMondaysDate, "Next Working Day",
        "Not Applicable"
    )
RETURN
    NextWorkingDay

Did I answer your question? Mark my post as a solution!
"Proud to be a Datanaut!"
Power BI Blog

View solution in original post

7 REPLIES 7
rajendran Super Contributor
Super Contributor

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Add another nested IF in next working day logic:

 

IF(TODAY()="Friday","Monday","next work day"

 

The above snippet will come after the underlined part.

 

Return day = IF(DateKey[Date]=TODAY()-1,"yesterday",IF(DateKey[Date]=TODAY()+1,"next work day",IF(DateKey[Date]=TODAY(),"today",("notapplicable"))))

 

Thanks

Raj

Jessica_Seiya Established Member
Established Member

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Believe someone else must have a smart way to go.

 

Basically, the following nest IF means to identify if Today is Friday or Saturday, if not, go use the common +1 logic to mark Next Working day; if it is Firday, +3 as the Next Working day, if it is Saturday, + 2 as the Next Workding day.

 

ReturnDay = 
IF (
    FORMAT ( TODAY (), "DDDD" ) <> "Friday"
        && FORMAT ( TODAY (), "DDDD" ) <> "Saturday",
    IF (
        'DateKey'[Date]
            = TODAY () - 1,
        "Yesterday",
        IF (
            'DateKey'[Date] = TODAY (),
            "Today",
            IF ( 'DateKey'[Date] = TODAY () + 1, "Next Work Day", "Notapplicable" )
        )
    ),
    IF (
        FORMAT ( TODAY (), "DDDD" ) = "Friday",
        IF (
            'DateKey'[Date]
                = TODAY () - 1,
            "Yesterday",
            IF (
                'DateKey'[Date] = TODAY (),
                "Today",
                IF ( 'DateKey'[Date] = TODAY () + 3, "Next Work Day", "Notapplicable" )
            )
        ),
        IF (
            FORMAT ( TODAY (), "DDDD" ) = "Saturday",
            IF (
                'DateKey'[Date]
                    = TODAY () - 1,
                "Yesterday",
                IF (
                    'DateKey'[Date] = TODAY (),
                    "Today",
                    IF ( 'DateKey'[Date] = TODAY () + 2, "Next Work Day", "Notapplicable" )
                )
            )
        )
    )
)

2018-06-29_10-28-01.png

 

View solution in original post

Super User
Super User

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Hi there

 

Here is the way I would do it with Variables and the SWITCH Statement

T/Y/Tom = 
VAR TodaysDate =
    TODAY ()
VAR YesterdayDate =
    TODAY () - 1
VAR NextMondaysDate =
    SWITCH(TRUE(),
        'Date'[Date] - WEEKDAY('DateKey'[Date],2)+1 >= TodaysDate, 'DateKey'[Date] - WEEKDAY('DateKey'[Date],2)+1,
        TODAY()-9
    )
VAR NextWorkingDay =
    SWITCH (
        TRUE (),
        'DateKey'[Date] = TodaysDate, "Today",
        'DateKey'[Date] = YesterdayDate, "Yesterday",
        'DateKey'[Date] = NextMondaysDate, "Next Working Day",
        "Not Applicable"
    )
RETURN
    NextWorkingDay

Did I answer your question? Mark my post as a solution!
"Proud to be a Datanaut!"
Power BI Blog

View solution in original post

v-jiascu-msft Super Contributor
Super Contributor

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Hi @Shem,

 


Can you mark the proper answer as a solution please?

 

Best Regards,

Dale

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

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Great, thanks this seemed to work as well as the formula above.

Shem Regular Visitor
Regular Visitor

Re: I am looking to return the next working day as tomorrow in a Power BI column.

Thank you sooo much for your reply. The query worked perfectly! Is there any chance you could indicate how i would alter this query so that Friday gave me the next 3 days instead of just the third day.

 

Sorry, a change in requirements from the powers above.

 

Thanks,

 

Shem

Shem Regular Visitor
Regular Visitor

Re: I am looking to return the next working day as tomorrow in a Power BI column.

For goe this i think i got my required formula using 'OR'

 

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 250 members 2,565 guests
Please welcome our newest community members: