Forum Discussion
Excluding Weekends - Returning data from Friday on Monday otherwise previous day data
Hello!
I'm trying to run a calculation that returns data for the previous day but on Monday, I need to return Friday's values.
I know that the PREVIOUSDAY function doesn't work and think that I have things narrowed down but am off on the syntax somewhere.
Trying to use IF, CALCULATE, DATEADD, and TODAY
I think I need to mix in the WEEKDAY function as well to show if today is Monday (or 1)
I'm trying to essentially say that IF (today) is a monday then I want to return the values from my CALCULATE function for Friday using the DATEADD function to go back 2 days otherwise just return the previous day. I'm trying to identify where to put the today equals function as well as my date table.
I have my calendar table with weekdays or weekday numbers.
Help please!!
Hi, Anonymous
You can try the following methods.
Column:
Weekday = WEEKDAY([Date],2)Measure:
Measure = IF ( SELECTEDVALUE ( 'Table'[Weekday] ) IN { 6, 7 }, BLANK (), IF ( SELECTEDVALUE ( 'Table'[Weekday] ) = 1, CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), [Date] = ( SELECTEDVALUE ( 'Table'[Date] ) - 3 ) ) ), CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), [Date] = ( SELECTEDVALUE ( 'Table'[Date] ) - 1 ) ) ) ) )Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandakSuper User
Anonymous , refer if this blog of mine can help
Traveling Across Workdays - What is next/previous Working day
https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calendar-4-5-Power/ba-p/1187766If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. - v-zhangtiCommunity Support
Hi, Anonymous
You can try the following methods.
Column:
Weekday = WEEKDAY([Date],2)Measure:
Measure = IF ( SELECTEDVALUE ( 'Table'[Weekday] ) IN { 6, 7 }, BLANK (), IF ( SELECTEDVALUE ( 'Table'[Weekday] ) = 1, CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), [Date] = ( SELECTEDVALUE ( 'Table'[Date] ) - 3 ) ) ), CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( ALL ( 'Table' ), [Date] = ( SELECTEDVALUE ( 'Table'[Date] ) - 1 ) ) ) ) )Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.