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
mogunase1
Helper III
Helper III

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 accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

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 accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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 accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@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")

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")

This working,

 

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

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.