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

Calc Column with next working day

Hello everyone,

I need to find a way to a dax formula for calculated column in a Calendar table which computes the "next working day" in the same table.

Basically i need to get the minimum DATE value, where IsWorkingDay is Y and DATE value is equal to or greater than the DATE fo current row - see attached image.

I tried some solutions but none worked 😞 (I admit i am quite new to DAX.. need to improve "on the job")

Help appreciated!

Thanks in advance

 

DAX next day.PNG

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

HI @bugs84

 

Hopefully this shall do the job

 

ThisOrNextWorkingDay =
VAR NextWorkingDay =
    MINX (
        FILTER (
            TableName,
            TableName[Day] > EARLIER ( TableName[Day] )
                && TableName[IsWorkingDay] = "Y"
        ),
        TableName[Day]
    )
RETURN
    IF ( TableName[IsWorkingDay] = "N", NextWorkingDay, TableName[Day] )

Regards
Zubair

Please try my custom visuals

View solution in original post

6 REPLIES 6
d_gullik
Frequent Visitor

Is there any way to use this measure as a calculated column in the fact table but the dates of next working day refers to customised date table?

Zubair_Muhammad
Community Champion
Community Champion

HI @bugs84

 

Hopefully this shall do the job

 

ThisOrNextWorkingDay =
VAR NextWorkingDay =
    MINX (
        FILTER (
            TableName,
            TableName[Day] > EARLIER ( TableName[Day] )
                && TableName[IsWorkingDay] = "Y"
        ),
        TableName[Day]
    )
RETURN
    IF ( TableName[IsWorkingDay] = "N", NextWorkingDay, TableName[Day] )

Regards
Zubair

Please try my custom visuals

I just joined the pwbi community to thank you for this. 5 years after posting and still a simple and valid solution.

It worked!!

Actually since i have a few rows, i guess removing the "IF" and making the measure a little simpler can be fine too.

Thanks a lot!!

 

ThisOrNextWorkingDay =
MINX (
    FILTER (
        ZDate;
        ZDate[Date] >= EARLIER ( ZDate[Date] )
            && ZDate[IsWorkingDay] = "S"
    );
    ZDate[Date]
)

@bugs84

 

1054.png


Regards
Zubair

Please try my custom visuals

Hi @Zubair_Muhammad this worked great!

 

I have a very large date table though and this seems to take quite some time to load, is there another way to do this for large date tables?

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.