Forum Discussion
Anonymous
7 years agoNot applicable
Subtract date/time based on text contained within a string
I have a ticketing system that audits field changes on ticket records. I am doing some research on how long it takes tickets to be raised in priority from low or medium to high or critical. I am also...
- 7 years ago
hi, Anonymous
After my research, you could do these as below:
Step1:
Use SEARCH or FIND Function to add a column that based on text contained.
contained = IF ( SEARCH ( "Priority: Critical", 'Table'[Field Changes], 1, 0 ) > 0, 0, IF ( SEARCH ( "Priority: High", 'Table'[Field Changes], 1, 0 ) > 0, 1, IF ( SEARCH ( "Priority: Medium", 'Table'[Field Changes], 1, 0 ) > 0, 2, IF ( SEARCH ( "Priority: Low", 'Table'[Field Changes], 1, 0 ) > 0, 3 ) ) ) )Note: Pay attention to the standard text format
Step2:
Add two measure by these formulas
Time to High/Critical = VAR _mindatetime0or1 = CALCULATE ( MIN ( 'Table'[AuditDate] ), ALLEXCEPT ( 'Table', 'Table'[IncidentID] ), FILTER ( 'Table', 'Table'[contained] = 0 || 'Table'[contained] = 1 ) ) RETURN DATEDIFF ( CALCULATE ( MIN ( 'Table'[AuditDate] ), ALLEXCEPT ( 'Table', 'Table'[IncidentID] ) ), _mindatetime0or1, MINUTE ) / 60Total Time = DATEDIFF ( CALCULATE ( MIN ( 'Table'[AuditDate] ), ALLEXCEPT ( 'Table', 'Table'[IncidentID] ) ), CALCULATE ( MAX ( 'Table'[AuditDate] ), ALLEXCEPT ( 'Table', 'Table'[IncidentID] ) ), MINUTE ) / 60Step3:
Format the decimal for two measure
Step4:
Drag IncidentID and two measure into visual
here is pbix, please try it.
Best Regards,
Lin
v-lili6-msft
Community Support
7 years ago
hi, Anonymous
After my research, you could do these as below:
Step1:
Use SEARCH or FIND Function to add a column that based on text contained.
contained =
IF (
SEARCH ( "Priority: Critical", 'Table'[Field Changes], 1, 0 ) > 0,
0,
IF (
SEARCH ( "Priority: High", 'Table'[Field Changes], 1, 0 ) > 0,
1,
IF (
SEARCH ( "Priority: Medium", 'Table'[Field Changes], 1, 0 ) > 0,
2,
IF ( SEARCH ( "Priority: Low", 'Table'[Field Changes], 1, 0 ) > 0, 3 )
)
)
)Note: Pay attention to the standard text format
Step2:
Add two measure by these formulas
Time to High/Critical =
VAR _mindatetime0or1 =
CALCULATE (
MIN ( 'Table'[AuditDate] ),
ALLEXCEPT ( 'Table', 'Table'[IncidentID] ),
FILTER ( 'Table', 'Table'[contained] = 0 || 'Table'[contained] = 1 )
)
RETURN
DATEDIFF (
CALCULATE (
MIN ( 'Table'[AuditDate] ),
ALLEXCEPT ( 'Table', 'Table'[IncidentID] )
),
_mindatetime0or1,
MINUTE
)
/ 60Total Time =
DATEDIFF (
CALCULATE (
MIN ( 'Table'[AuditDate] ),
ALLEXCEPT ( 'Table', 'Table'[IncidentID] )
),
CALCULATE (
MAX ( 'Table'[AuditDate] ),
ALLEXCEPT ( 'Table', 'Table'[IncidentID] )
),
MINUTE
)
/ 60Step3:
Format the decimal for two measure
Step4:
Drag IncidentID and two measure into visual
here is pbix, please try it.
Best Regards,
Lin