Forum Discussion
Calculated column for work hour
- 6 years ago
Thanks AlB for the effort. Also, I'll try to share the table model in further post. Sharing PBIX would not be possible.
The following code worked out.
Work Hour = VAR currentdate = CALCULATE ( MIN ( 'Build routing'[Date] ) ) VAR mintime = CALCULATE ( MIN ( 'Build routing'[End Time] ), ALLEXCEPT ( 'Build routing', 'Build routing'[Date], 'Build routing'[Unit Status] ) ) VAR starthour = HOUR ( mintime ) VAR currenthour = HOUR ( 'Build routing'[End Time] ) RETURN currenthour - starthour + 1This code resulted in the following
Thanks for the effort.
Hi vissvess
Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. A screen cap doesn't allow people to readily copy the data and run a quick test and thus decreases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).
Try this (untested)
NewCol =
RANKX (
FILTER (
Table1,
Table1[Date] = EARLIER ( Table1[Date] ) && Table1[Unit Status] = EARLIER ( Table1[Unit Status] )
),
Table1[Start Time],
,
DESC
)
Please mark the question solved when done and consider giving kudos if posts are helpful.
Cheers ![]()
Thanks AlB for the effort. Also, I'll try to share the table model in further post. Sharing PBIX would not be possible.
The following code worked out.
Work Hour =
VAR currentdate =
CALCULATE ( MIN ( 'Build routing'[Date] ) )
VAR mintime =
CALCULATE (
MIN ( 'Build routing'[End Time] ),
ALLEXCEPT (
'Build routing',
'Build routing'[Date],
'Build routing'[Unit Status]
)
)
VAR starthour =
HOUR ( mintime )
VAR currenthour =
HOUR ( 'Build routing'[End Time] )
RETURN
currenthour - starthour + 1This code resulted in the following
Thanks for the effort.