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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
NewbieJono
Post Partisan
Post Partisan

Filter - Previous working day

i have this code to identify "today". is there a method i could use to also identify previous working day, ihave a coloumn that indicates if its a working day or not and returns 1,0

 

WorkingDay = if(WEEKDAY([Date],2) >=6,0,1)

Is Today =
var _max = maxx(filter('Date', 'Date'[Date] <=today() && [WorkingDay] =1),'Date'[Date])
return
Switch(True(),
[Date] = _max, "Today",
Format([Date], "DD/MM/YYYY"))

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @NewbieJono 

 

So you are doing 2 Calculated columns? your "today" is not actually today, but working day...you want something like this?

 

Vera_33_0-1621582536014.png

test = 
var workingDays = filter('Date', 'Date'[Date] <=today() && [WorkingDay] =1)
var today = MAXX(workingDays,[Date])
var previous = MAXX(FILTER(workingDays,[Date]<today),[Date])
return
SWITCH(TRUE(),
[Date]=today,"Today",
[Date] = previous, "Previous Working Day",
Format([Date], "DD/MM/YYYY"))

 

View solution in original post

5 REPLIES 5
NewbieJono
Post Partisan
Post Partisan

thanks for your time both

Vera_33
Resident Rockstar
Resident Rockstar

Hi @NewbieJono 

 

So you are doing 2 Calculated columns? your "today" is not actually today, but working day...you want something like this?

 

Vera_33_0-1621582536014.png

test = 
var workingDays = filter('Date', 'Date'[Date] <=today() && [WorkingDay] =1)
var today = MAXX(workingDays,[Date])
var previous = MAXX(FILTER(workingDays,[Date]<today),[Date])
return
SWITCH(TRUE(),
[Date]=today,"Today",
[Date] = previous, "Previous Working Day",
Format([Date], "DD/MM/YYYY"))

 

I would like to calculate two/three/four previous working days, how do I do ?

Hi @juliabot 

 

Try it

test = 
var workingDays = filter('Date', 'Date'[Date] <=today() && [WorkingDay] =1)
var today = MAXX(workingDays,[Date])
var previous = MAXX(FILTER(workingDays,[Date]<today),[Date])
var pre2day = MAXX(FILTER(workingDays,[Date]< previous),[Date])
return
SWITCH(TRUE(),
[Date]=today,"Today",
[Date] = previous, "Previous Working Day",
[Date] = pre2day, "Previous 2 Working Day",
Format([Date], "DD/MM/YYYY"))

 

amitchandak
Super User
Super User

@NewbieJono ,

 

Last working  = maxx(filter('Date', 'Date'[Date] <today() && [WorkingDay] =1),'Date'[Date])

 

Also refer my blog

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.