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
KhrystinaM
Helper I
Helper I

Date slicer showing previous day excluding weekends.

Hello, I have a PowerBI dashboard where I only want to see data from the prior business date. Is there a formula I can write for this?

2 ACCEPTED SOLUTIONS
v-yohua-msft
Community Support
Community Support

Hi, @KhrystinaM 


Based on your information, I create a table:

 

vyohuamsft_0-1706692730278.png

 

Please following these steps:

  1. Create a new column named PreviousData, and use the following DAX expression:

 

vyohuamsft_1-1706692730280.png

 

PreviousData =

VAR a = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[Date]=EARLIER('Table'[Date])-1))

RETURN

IF(WEEKDAY('Table'[Date])=1||WEEKDAY('Table'[Date])-1=7||WEEKDAY('Table'[Date])-1=1,BLANK(),a)

 

  1. Then create a dashboard, put previousData into the dashboard, create a slicer, and put the Date in, when we select the Date, the dashboard will show the information of the previous day, and will not return the weekend.

 

1.png

 

2.png

 

 

For example, if I select the date as Monday, he will not display the data for Sunday.

 

3.png

If I select a date on Saturday, it will show the value of the previous day, which is Friday.

 

4.png

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Hi, @KhrystinaM 
Create a new column in the home page instead of Custom Column in Power Query
.

vyohuamsft_0-1706750695248.png

 

Powe Query uses M and mine is a DAX expression, so it gets an error in Power Query.

Try selecting New column under Modeling and using DAX again.

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-yohua-msft
Community Support
Community Support

Hi, @KhrystinaM 


Based on your information, I create a table:

 

vyohuamsft_0-1706692730278.png

 

Please following these steps:

  1. Create a new column named PreviousData, and use the following DAX expression:

 

vyohuamsft_1-1706692730280.png

 

PreviousData =

VAR a = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),'Table'[Date]=EARLIER('Table'[Date])-1))

RETURN

IF(WEEKDAY('Table'[Date])=1||WEEKDAY('Table'[Date])-1=7||WEEKDAY('Table'[Date])-1=1,BLANK(),a)

 

  1. Then create a dashboard, put previousData into the dashboard, create a slicer, and put the Date in, when we select the Date, the dashboard will show the information of the previous day, and will not return the weekend.

 

1.png

 

2.png

 

 

For example, if I select the date as Monday, he will not display the data for Sunday.

 

3.png

If I select a date on Saturday, it will show the value of the previous day, which is Friday.

 

4.png

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yohua-msft, thank you for your reply. The calcuate function is throwing an error. 

 

KhrystinaM_0-1706721526600.png

 

Hi, @KhrystinaM 
Create a new column in the home page instead of Custom Column in Power Query
.

vyohuamsft_0-1706750695248.png

 

Powe Query uses M and mine is a DAX expression, so it gets an error in Power Query.

Try selecting New column under Modeling and using DAX again.

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That worked, thank you!!

PijushRoy
Super User
Super User

Hi @KhrystinaM 

Your message header and body little confusing
You are taking about Slicer data or filter data in Other visual

Can you share details, expected result and screenshot

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.