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.
I created a Date column that populates each row with the planned delivery date if that date is in the next 7 days.
As such if today is January 26, the column will be populated with dates from Jan-26 to Feb 1. (The next 7 days)
I would like Weekends not to be included. So the next 7 days from Jan 26 should includes Dates from Jan 26 to Feb 3 excluding Jan 29 and Jan 30 (Saturday and Sunday).
Basically the next 7 working days since we don't deliver on weekends.
Any help will be appreciated
Solved! Go to Solution.
Hi @vincetaylor ,
Create a related DimDate table and then create a measure to filter your visual.
Date =
VAR _Date =
ADDCOLUMNS (
CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"YearMonth",
YEAR ( [Date] ) * 100
+ MONTH ( [Date] ),
"Day", DAY ( [Date] ),
"DayName", FORMAT ( [Date], "DDDD" )
)
VAR _ADDRANK =
ADDCOLUMNS (
_Date,
"RANK",
VAR _RANK =
RANKX (
FILTER ( _Date, NOT ( [DayName] IN { "Saturday", "Sunday" } ) ),
[Date],
,
ASC
)
RETURN
IF ( NOT ( [DayName] IN { "Saturday", "Sunday" } ), _RANK,_RANK )
)
RETURN
_ADDRANK
Measure:
Measure =
VAR _DAYNAMETODAY = CALCULATE(MAX('Date'[DayName]),FILTER(ALL('Date'),'Date'[Date] = TODAY()))
VAR _RANKTODAY = CALCULATE(SUM('Date'[RANK]),FILTER(ALL('Date'),'Date'[Date] = TODAY()))
VAR _RANKADD7 = _RANKTODAY+7
VAR _CURRENTRANK = SUM('Date'[RANK])
RETURN
if(_DAYNAMETODAY IN{"Saturday","Sunday"},IF(_CURRENTRANK >=_RANKTODAY&&_CURRENTRANK<_RANKADD7&&NOT(MAX('Date'[DayName])IN{"Saturday","Sunday"}),1,0), IF(_CURRENTRANK >_RANKTODAY&&_CURRENTRANK<=_RANKADD7&&NOT(MAX('Date'[DayName])IN{"Saturday","Sunday"}),1,0))
Create a visual, add this measure in visual level filter field and set it to show items when value =1.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @vincetaylor ,
Create a related DimDate table and then create a measure to filter your visual.
Date =
VAR _Date =
ADDCOLUMNS (
CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] ),
"YearMonth",
YEAR ( [Date] ) * 100
+ MONTH ( [Date] ),
"Day", DAY ( [Date] ),
"DayName", FORMAT ( [Date], "DDDD" )
)
VAR _ADDRANK =
ADDCOLUMNS (
_Date,
"RANK",
VAR _RANK =
RANKX (
FILTER ( _Date, NOT ( [DayName] IN { "Saturday", "Sunday" } ) ),
[Date],
,
ASC
)
RETURN
IF ( NOT ( [DayName] IN { "Saturday", "Sunday" } ), _RANK,_RANK )
)
RETURN
_ADDRANK
Measure:
Measure =
VAR _DAYNAMETODAY = CALCULATE(MAX('Date'[DayName]),FILTER(ALL('Date'),'Date'[Date] = TODAY()))
VAR _RANKTODAY = CALCULATE(SUM('Date'[RANK]),FILTER(ALL('Date'),'Date'[Date] = TODAY()))
VAR _RANKADD7 = _RANKTODAY+7
VAR _CURRENTRANK = SUM('Date'[RANK])
RETURN
if(_DAYNAMETODAY IN{"Saturday","Sunday"},IF(_CURRENTRANK >=_RANKTODAY&&_CURRENTRANK<_RANKADD7&&NOT(MAX('Date'[DayName])IN{"Saturday","Sunday"}),1,0), IF(_CURRENTRANK >_RANKTODAY&&_CURRENTRANK<=_RANKADD7&&NOT(MAX('Date'[DayName])IN{"Saturday","Sunday"}),1,0))
Create a visual, add this measure in visual level filter field and set it to show items when value =1.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@vincetaylor , refer if my blog on the same can help
Traveling Across Workdays - What is next/previous Working day
https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calenda...
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
75 | |
65 | |
53 |
User | Count |
---|---|
144 | |
103 | |
98 | |
85 | |
64 |