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.
Hi,
what I am trying to do is to create a new column (measure) that will calculate the differences between pick begin AND pick end. The result should be in minutes.
The format is like below:
pick begin | pick end | result |
1145 | 1218 | 33 |
2110 | 2125 | 15 |
1907 | 1907 | 0 |
0710 | 0710 | 0 |
0321 | 0333 | 2 |
1621 | 1634 | 13 |
1334 | 1401 | 27 |
0135 | 0147 | 12 |
2336 | 2336 | 0 |
Solved! Go to Solution.
@Anonymous
This is not my measure. You can also try by defining a new column as per the calculated column code that I've provided
DEFINE
COLUMN 'Pick Order'[Column Result] =
VAR PickBegin =
VALUE ( RIGHT ( 'Pick Order'[PICK Time pick begin], 2 ) ) + 60 * VALUE ( LEFT ( 'Pick Order'[PICK Time pick begin], 2 ) )
VAR PickEnd =
VALUE ( RIGHT ( 'Pick Order'[PICK Time pick end], 2 ) ) + 60 * VALUE ( LEFT ( 'Pick Order'[PICK Time pick end], 2 ) )
RETURN
PickEnd - PickBegin
EVALUATE
SUMMARIZECOLUMNS (
'Pick Order'[PICK Time pick begin],
'Pick Order'[PICK Time pick end],
'Pick Order'[Column Result]
)
Thank you all for your reply. I am using ReportBuilder, testing in DaxStudio. Working on PowerBI DataSets.
And does not matter which of your solution I will choose I am receiving errors like:
"The result set of a query to external data source has exceeded the maximum allowed size"
DAX code:
DEFINE
MEASURE 'Pick Measures'[Time] =
VAR _hourbegin =
LEFT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick begin]), 2 )
VAR _minbegin =
RIGHT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick begin] ), 2 )
VAR _hourend =
LEFT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick end] ), 2 )
VAR _minend =
RIGHT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick end] ), 2 )
VAR _timebegin = _hourbegin * 60 + _minbegin
VAR _timeend = _hourend * 60 + _minend
RETURN
_timeend - _timebegin
EVALUATE
SUMMARIZECOLUMNS (
'Pick DC'[PDC Number],
'Pick Date'[PD Date],
'Pick Order'[PICK Order number],
'Pick Order'[PICK Order pickgroup],
'Sales Order'[SO Order Number],
'Material'[MAT Temperature Zone Description],
'Material'[MAT Business ID],
'Pick Order'[PICK Time pick begin],
'Pick Order'[PICK Time pick end],
'Employee'[EMPL Name],
FILTER (
VALUES ( 'Pick DC'[PDC Country] ),
'Pick DC'[PDC Country] = "USA"
),
FILTER (
VALUES ( 'Pick DC'[PDC Number] ),
'Pick DC'[PDC Number] <> 100
),
FILTER (
'Pick Date',
'Pick Date'[PD Date]
= TODAY () - 1
),
"Picked Quantity", [Picked Quantity],
"Picked Net Weight (Kg)", [Picked Net Weight (Kg)],
"Picked Gross Weight (Kg)", [Picked Gross Weight (Kg)],
"Time",'Pick Measures'[Time]
)
Hi @Anonymous
Here is a sample file with the solution https://www.dropbox.com/t/OmLvgOdd6iXtXTbt
For a calculated column
Result =
VAR PickBegin =
VALUE ( RIGHT ( Timing[ pick begin ], 2 ) ) + 60 * VALUE ( LEFT ( Timing[ pick begin ], 2 ) )
VAR PickEnd =
VALUE ( RIGHT ( Timing[ pick end ], 2 ) ) + 60 * VALUE ( LEFT ( Timing[ pick end ], 2 ) )
RETURN
PickEnd - PickBegin
For a measure
Result Measure =
VAR PickBegin =
SUMX (
Timing,
VALUE ( RIGHT ( Timing[ pick begin ], 2 ) ) + 60 * VALUE ( LEFT ( Timing[ pick begin ], 2 ) )
)
VAR PickEnd =
SUMX (
Timing,
VALUE ( RIGHT ( Timing[ pick end ], 2 ) ) + 60 * VALUE ( LEFT ( Timing[ pick end ], 2 ) )
)
RETURN
PickEnd - PickBegin
Thank you all for your reply. I am using ReportBuilder, testing in DaxStudio. Working on PowerBI DataSets.
And does not matter which of your solution I will choose I am receiving errors like:
"The result set of a query to external data source has exceeded the maximum allowed size"
DAX code:
DEFINE
MEASURE 'Pick Measures'[Time] =
VAR _hourbegin =
LEFT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick begin]), 2 )
VAR _minbegin =
RIGHT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick begin] ), 2 )
VAR _hourend =
LEFT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick end] ), 2 )
VAR _minend =
RIGHT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick end] ), 2 )
VAR _timebegin = _hourbegin * 60 + _minbegin
VAR _timeend = _hourend * 60 + _minend
RETURN
_timeend - _timebegin
EVALUATE
SUMMARIZECOLUMNS (
'Pick DC'[PDC Number],
'Pick Date'[PD Date],
'Pick Order'[PICK Order number],
'Pick Order'[PICK Order pickgroup],
'Sales Order'[SO Order Number],
'Material'[MAT Temperature Zone Description],
'Material'[MAT Business ID],
'Pick Order'[PICK Time pick begin],
'Pick Order'[PICK Time pick end],
'Employee'[EMPL Name],
FILTER (
VALUES ( 'Pick DC'[PDC Country] ),
'Pick DC'[PDC Country] = "USA"
),
FILTER (
VALUES ( 'Pick DC'[PDC Number] ),
'Pick DC'[PDC Number] <> 100
),
FILTER (
'Pick Date',
'Pick Date'[PD Date]
= TODAY () - 1
),
"Picked Quantity", [Picked Quantity],
"Picked Net Weight (Kg)", [Picked Net Weight (Kg)],
"Picked Gross Weight (Kg)", [Picked Gross Weight (Kg)],
"Time",'Pick Measures'[Time]
)
@Anonymous
This is not my measure. You can also try by defining a new column as per the calculated column code that I've provided
DEFINE
COLUMN 'Pick Order'[Column Result] =
VAR PickBegin =
VALUE ( RIGHT ( 'Pick Order'[PICK Time pick begin], 2 ) ) + 60 * VALUE ( LEFT ( 'Pick Order'[PICK Time pick begin], 2 ) )
VAR PickEnd =
VALUE ( RIGHT ( 'Pick Order'[PICK Time pick end], 2 ) ) + 60 * VALUE ( LEFT ( 'Pick Order'[PICK Time pick end], 2 ) )
RETURN
PickEnd - PickBegin
EVALUATE
SUMMARIZECOLUMNS (
'Pick Order'[PICK Time pick begin],
'Pick Order'[PICK Time pick end],
'Pick Order'[Column Result]
)
Thank you, that is perfect!
It's supposed to use PQ to conduct such a data shaping task.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jc3BDcAwCAPAXXj3gTFJ2lmi7L9GY3iZkxHsbUAOewyB186zLQC/DsQo4/OlXiH7qr6izIBMsvdnGZPZ5h2u09H7oP45su8FOfVPcc4P", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"pick begin" = _t, #"pick end" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"pick begin", Int64.Type}, {"pick end", Int64.Type}}),
TotalMinutes = Table.AddColumn(#"Changed Type", "Total Minutes",
each let
begin=#time(Number.IntegerDivide([pick begin],100), Number.Mod([pick begin],100),0),
end = #time(Number.IntegerDivide([pick end],100), Number.Mod([pick end],100),0)
in Duration.TotalMinutes(end-begin)
)
in
TotalMinutes
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi, thank you. I am not able to use PQ
Hi,
Please check the below measure and the attached pbix file.
Result measure: =
VAR _hourbegin =
LEFT ( SELECTEDVALUE ( Data[pick begin] ), 2 )
VAR _minbegin =
RIGHT ( SELECTEDVALUE ( Data[pick begin] ), 2 )
VAR _hourend =
LEFT ( SELECTEDVALUE ( Data[pick end] ), 2 )
VAR _minend =
RIGHT ( SELECTEDVALUE ( Data[pick end] ), 2 )
VAR _timebegin = _hourbegin * 60 + _minbegin
VAR _timeend = _hourend * 60 + _minend
RETURN
_timeend - _timebegin
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
@Anonymous Maybe this and make sure you set the Data type to Whole number:
result = (TIME(LEFT([pick end],2), RIGHT([pick end],2),0) - TIME(LEFT([pick begin],2), RIGHT([pick begin],2),0)) * 60 * 24
Thank you all for your reply. I am using ReportBuilder, testing in DaxStudio. Working on PowerBI DataSets.
And does not matter which of your solution I will choose I am receiving errors like:
"The result set of a query to external data source has exceeded the maximum allowed size"
DAX code:
DEFINE
MEASURE 'Pick Measures'[Time] =
VAR _hourbegin =
LEFT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick begin]), 2 )
VAR _minbegin =
RIGHT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick begin] ), 2 )
VAR _hourend =
LEFT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick end] ), 2 )
VAR _minend =
RIGHT ( SELECTEDVALUE ( 'Pick Order'[PICK Time pick end] ), 2 )
VAR _timebegin = _hourbegin * 60 + _minbegin
VAR _timeend = _hourend * 60 + _minend
RETURN
_timeend - _timebegin
EVALUATE
SUMMARIZECOLUMNS (
'Pick DC'[PDC Number],
'Pick Date'[PD Date],
'Pick Order'[PICK Order number],
'Pick Order'[PICK Order pickgroup],
'Sales Order'[SO Order Number],
'Material'[MAT Temperature Zone Description],
'Material'[MAT Business ID],
'Pick Order'[PICK Time pick begin],
'Pick Order'[PICK Time pick end],
'Employee'[EMPL Name],
FILTER (
VALUES ( 'Pick DC'[PDC Country] ),
'Pick DC'[PDC Country] = "USA"
),
FILTER (
VALUES ( 'Pick DC'[PDC Number] ),
'Pick DC'[PDC Number] <> 100
),
FILTER (
'Pick Date',
'Pick Date'[PD Date]
= TODAY () - 1
),
"Picked Quantity", [Picked Quantity],
"Picked Net Weight (Kg)", [Picked Net Weight (Kg)],
"Picked Gross Weight (Kg)", [Picked Gross Weight (Kg)],
"Time",'Pick Measures'[Time]
)
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 |
---|---|
41 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
36 | |
33 | |
18 | |
18 |