March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello guys.
I am trying to create a meassure that only counts week days to calculate the delivery for an item.
I have a purchasing lead time of 10 days, if the order is entered today 06/12/2020, the estimated time of delivery should be 06/25/2020
Part Lead time Delivery date
123 10 ???
I know it sounds easy, I have tried different methods with no luck.
Solved! Go to Solution.
Hi @carlosagarcia ,
You need to create a date dimension.
Date =
CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2020, 12, 31 ) )
Then create columns to show working days and running total.
Count =
VAR a = WEEKDAY ( 'Date'[Date], 2 ) RETURN IF ( a < 6, 1, 0 )
Sum =
CALCULATE (
SUM ( 'Date'[Count] ),
FILTER ( 'Date', 'Date'[Date] <= EARLIER ( 'Date'[Date] ) )
)
Create a measure to show date.
Measure =
VAR a =
SELECTEDVALUE ( 'Table'[Date] )
VAR b =
SELECTEDVALUE ( 'Table'[Days] )
VAR c =
CALCULATE ( MAX ( 'Date'[Sum] ), FILTER ( 'Date', 'Date'[Date] = a ) )
RETURN
CALCULATE (
MAX ( 'Date'[Date] ),
FILTER ( 'Date', 'Date'[Sum] = b + c - 1 && 'Date'[Count] = 1 )
)
Here is my test file for your reference.
Hi @carlosagarcia ,
You need to create a date dimension.
Date =
CALENDAR ( DATE ( 2020, 01, 01 ), DATE ( 2020, 12, 31 ) )
Then create columns to show working days and running total.
Count =
VAR a = WEEKDAY ( 'Date'[Date], 2 ) RETURN IF ( a < 6, 1, 0 )
Sum =
CALCULATE (
SUM ( 'Date'[Count] ),
FILTER ( 'Date', 'Date'[Date] <= EARLIER ( 'Date'[Date] ) )
)
Create a measure to show date.
Measure =
VAR a =
SELECTEDVALUE ( 'Table'[Date] )
VAR b =
SELECTEDVALUE ( 'Table'[Days] )
VAR c =
CALCULATE ( MAX ( 'Date'[Sum] ), FILTER ( 'Date', 'Date'[Date] = a ) )
RETURN
CALCULATE (
MAX ( 'Date'[Date] ),
FILTER ( 'Date', 'Date'[Sum] = b + c - 1 && 'Date'[Count] = 1 )
)
Here is my test file for your reference.
Hello,
I am ready to test your answer but I get stuck on the Messure column.
I get an error on
Hi @carlosagarcia ,
Change it to be TODAY() or TODAY()+1.
var a = TODAY()
Make sure that the date dimension have all dates you need in the future.
Thank you, worked like a charm.
@carlosagarcia , Have a date table with following field
Table
Date = CALENDAR(date(2018,01,01), date(2021,12,31))
Columns
Work Day = if(WEEKDAY([Date],2)>=6,0,1)
Work Date = if(WEEKDAY([Date],2)>=6,BLANK(),[Date])
Work Date Cont = if([Work Day]=0,maxx(FILTER('Date',[Date]<EARLIER([Date]) && [Work Day]<> EARLIER([Work Day]) ),[Date]),[Date])
Work Date cont Rank = RANKX(ALL('Date'),[Work Date Cont],,ASC,Dense)
Use Rank to Travel . Example Measure
Plus 10 Days = var _max =maxx(ALLSELECTED('Date'),'Date'[Work Date cont Rank])
return CALCULATE(Min('Date'[Date]),filter(ALL('Date'),'Date'[Work Date Rank] =_max+10))
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...
Appreciate your Kudos.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |