cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mogunase1
Helper I
Helper I

Custom Date filter - Today and last business day

Hi,

 

I need filter with date holding "Todays" , "Last Business Day" ,"Yesterday","All other".

 

I tried puting up some column in Calendar table but i didnt get any proper result for last working day- i.e., last businesss day (when i use this filter Monday, last business day will be Friday)

Please help me here.

 

Thanks,

Mohanraj.

 

@amitchandak , @Jihwan_Kim 

1 ACCEPTED SOLUTION

Hi, @mogunase1 

Thank you for your feedback.

Sorry to say that I am still not sure whether I understood your question correctly.

I assume you wanted to describe a slicer.

Please check the below picture and the sample pbix file's link down below.

I changed one of the measures to show as keeping the filter option in the measure by adding a KEEPFILTER function.

 

Picture1.png

 

Qty Total Filter Measure =
VAR lastworkingday =
CALCULATE (
MAX ( Dates[Date] ),
FILTER (
ALL ( Dates ),
Dates[Date] < TODAY ()
&& AND ( Dates[Day of Week] <> 6, Dates[Day of Week] <> 0 )
)
)
RETURN
SWITCH (
SELECTEDVALUE ( Slicer[Index],1 ),
1, CALCULATE ( [Qty Total], KEEPFILTERS(Dates[Date] = TODAY () )),
2, CALCULATE ( [Qty Total], KEEPFILTERS(Dates[Date] = lastworkingday )),
3,
CALCULATE ( [Qty Total], KEEPFILTERS(Dates[Date] = TODAY () - 1 )),
4,
CALCULATE (
[Qty Total],
KEEPFILTERS(FILTER (
ALL ( Dates ),
Dates[Date]
<= TODAY () - 2
&& Dates[Date] <> lastworkingday)
)
)
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

5 REPLIES 5
Jihwan_Kim
Community Champion
Community Champion

Hi, @mogunase1 

I am not quite sure if I understood your question correctly.

I tried to create a sample pbix file based on the explanation.

Please check the below picture and the sample pbix file's link down below, whether it is what you are looking for.

 

All measures are in the sample pbix file.

 

Picture2.png

 

https://www.dropbox.com/s/f4z9qaput5743so/mogunasev3.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Hi Jihwan,

 

Actually i need date filter which has Today - Data which needs to show only todays data alone(i.e, 18th May 2021).

Yesterday - Data which needs to show yesterday data alone( 17th May 2021).

 

And incase if i use this filter on Monday (i.e., 24th May 2021) that time i will use "last business day" - Because there will be no data in Saturday and Sunday.

 

So, Last Business Day - needs to Friday (i.e, 21st May 2021)  - But this filter i will use only on Monday.

 

I hope you understand my issue now.

 

Thanks,

Mohanraj

Hi, @mogunase1 

Thank you for your feedback.

Sorry to say that I am still not sure whether I understood your question correctly.

I assume you wanted to describe a slicer.

Please check the below picture and the sample pbix file's link down below.

I changed one of the measures to show as keeping the filter option in the measure by adding a KEEPFILTER function.

 

Picture1.png

 

Qty Total Filter Measure =
VAR lastworkingday =
CALCULATE (
MAX ( Dates[Date] ),
FILTER (
ALL ( Dates ),
Dates[Date] < TODAY ()
&& AND ( Dates[Day of Week] <> 6, Dates[Day of Week] <> 0 )
)
)
RETURN
SWITCH (
SELECTEDVALUE ( Slicer[Index],1 ),
1, CALCULATE ( [Qty Total], KEEPFILTERS(Dates[Date] = TODAY () )),
2, CALCULATE ( [Qty Total], KEEPFILTERS(Dates[Date] = lastworkingday )),
3,
CALCULATE ( [Qty Total], KEEPFILTERS(Dates[Date] = TODAY () - 1 )),
4,
CALCULATE (
[Qty Total],
KEEPFILTERS(FILTER (
ALL ( Dates ),
Dates[Date]
<= TODAY () - 2
&& Dates[Date] <> lastworkingday)
)
)
)
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

amitchandak
Super User IV
Super User IV

@mogunase1 , Try a new column like

 

Date Type = SWITCH(TRUE(),'Date'[Date]=TODAY(),"Today"
'Date'[Date]=maxx(filter('Date', 'Date'[Date] < Today() && WEEKDAY([Date],2) <6),[Date]) , "Last Business Day"
,'Date'[Date]=TODAY()-1,"Yesterday"
,"All")



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

tried using Switch and if conditon - last working day is not coming.

working Days = IF('Date'[Date] = TODAY(),"Today",IF('Date'[Date]=TODAY()-1,"Yesterday",IF('Date'[Date]=MAXX(FILTER('Date','Date'[Date]< TODAY() && WEEKDAY('Date'[Date],2)<6),'Date'[Date]),"Last Business Day","All Other Day")))
 
 
Date Type = SWITCH(TRUE(),'Date'[Date]=TODAY(),"Today",'Date'[Date]=MAXX(FILTER('Date','Date'[Date]< TODAY() && WEEKDAY('Date'[Date],2)<6),'Date'[Date]),"Last Business Day", 'Date'[Date]=TODAY()-1,"Yesterday")

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors