Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
aramirez2
Helper I
Helper I

Previous working day column

Hi!

 

I need to create a previous working day column in my calendar table which has the following structure:

 

Captura.PNG

 

WorkingDay column = "1" means that we opened our store and I need for each Date value which was the previous day we opened the store. However I am not able to reach my goal because:

 

PrevWorkingDay column works properly from Tuesday to Saturday.
 
PrevWorkingDay2 column works properly for the last week.
 
PrevWorkingDay3 only shows up the last working day.
 
May anyone help me please?
 
Thanks in advance.
 
Regards.
1 ACCEPTED SOLUTION

Thanks @amitchandak  but your Work Date Cont column gives today date (Monday) for today record as Previous Work Day. 

 

I got the solution. Now PrevWorkDay column gives Friday as Previous Work Day for Saturday, Sunday and Monday records.

 

Captura.PNG

 

 

 

PreviousWorkDay = 
var a = Hoja1[Date]
RETURN CALCULATE(MAX(Hoja1[Date]); FILTER(ALL(Hoja1); Hoja1[Date] < a && Hoja1[WorkingDay] = 1))

 

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@aramirez2 , You need few columns in date table

 

Work Day = if(WEEKDAY([Date],2)>=6,0,1)
Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])
Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
Work Date cont Rank = RANKX(ALL('Date'),[Work Date Cont],,ASC,Dense)
Work day of month = Sumx(filter(Date, [Month year] = earlier([Month year])),[Work Day])
Work day of week = Sumx(filter(Date, [Weekyear] = earlier([Weekyear])),[Work Day])

 

measures

This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Work Date cont Rank]=max('Date'[Work Date cont Rank])))
Last work day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Work Date cont Rank]=max('Date'[Work Date cont Rank])-1))
diff =[This Day] - [Last work day]

 

 

Traveling Across Workdays - What is next/previous Working day
https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calenda...

The measures like

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak

 

Thanks for your answer. However your formulas does not seem to show the desired result:

 

aramirez2_2-1614610986299.png

 

 

I have already created Workday column with "1" and "0" values. This data is correct and PrevWorkDay is nearly to work properly. I would like to fill up Blank PrevWorkDay cells with the very last work day.

 

@aramirez2 , I think, in the blog I shared I have updated nonworking dates with the last working dates 

 

Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak  but your Work Date Cont column gives today date (Monday) for today record as Previous Work Day. 

 

I got the solution. Now PrevWorkDay column gives Friday as Previous Work Day for Saturday, Sunday and Monday records.

 

Captura.PNG

 

 

 

PreviousWorkDay = 
var a = Hoja1[Date]
RETURN CALCULATE(MAX(Hoja1[Date]); FILTER(ALL(Hoja1); Hoja1[Date] < a && Hoja1[WorkingDay] = 1))

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors