Forum Discussion
Time to event formatted based on a value
I have a column which means time to conversion (time between start of a session and end of a session). It is is seconds
I also have a slicer where I can pick the number of sessions between these two times
I want to format the time to conversion based on the slicer select, so that if I chose "1 session" then this time to conv is divided by 60 (shows in minutes), if other slicer is selected, or all, then I want to show it in hours.
I have this and it does not work:
Time to Conv Display =
IF(
SELECTEDVALUE(purchase_path[Total Sessions Band]) = "1 session",
AVERAGE(purchase_path[time_to_conversion]) / 60,
AVERAGE(purchase_path[time_to_conversion]) / 3600
)
Anonymous
Time to Conv Display =
VAR ConversionTime =
IF(
SELECTEDVALUE(purchase_path[Total Sessions Band]) = "1 session",
AVERAGE(purchase_path[time_to_conversion]) / 60, -- Converts to minutes
AVERAGE(purchase_path[time_to_conversion]) / 3600 -- Converts to hours
)
RETURN
IF(
SELECTEDVALUE(purchase_path[Total Sessions Band]) = "1 session",
FORMAT(ConversionTime, "0.0") & " mins",
FORMAT(ConversionTime, "0.0") & " hrs"
)
7 Replies
- shafiz_p
Super User
Hi Anonymous Try this:
Time to Conv Display = VAR SelectedSession = SELECTEDVALUE(purchase_path[Total Sessions Band]) VAR TimeToConv = AVERAGE(purchase_path[time_to_conversion]) RETURN SWITCH( TRUE(), SelectedSession = "1 session", TimeToConv / 60, TimeToConv / 3600 )Hope this helps!!
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz- AnonymousNot applicable
- shafiz_p
Super User
This should work but unfortunately
SELECTEDVALUE(purchase_path[Total Sessions Band])unable to capture correct session. You slicer have different value like 1, 2, 3 than "1 Session". Please change accordingly if not.
Also try debugging by using the measure:Time to Conv Display = VAR SelectedSession = SELECTEDVALUE(purchase_path[Total Sessions Band]) VAR TimeToConv = AVERAGE(purchase_path[time_to_conversion]) RETURN SelectedSessionCheck what value it is returning. If returning value is same as condition right hand side value and same data type then it should return correct value.
If still not solved your problem, please share dummy data and data model you are managing to evaluate.
- vojtechsima
Super User
Hello, Anonymous ,
create table like this:hour thingy = var _selectedMeasurement = SELECTEDVALUE('Table'[value]) var result = AVERAGE(purchase_path[time_to_conversion]) / _selectedMeasurement return result
and then it will take whatever you chose from the slicer, make sure it's Singe Select - Kedar_Pande
Super User
Anonymous
Time to Conv Display =
VAR ConversionTime =
IF(
SELECTEDVALUE(purchase_path[Total Sessions Band]) = "1 session",
AVERAGE(purchase_path[time_to_conversion]) / 60, -- Converts to minutes
AVERAGE(purchase_path[time_to_conversion]) / 3600 -- Converts to hours
)
RETURN
IF(
SELECTEDVALUE(purchase_path[Total Sessions Band]) = "1 session",
FORMAT(ConversionTime, "0.0") & " mins",
FORMAT(ConversionTime, "0.0") & " hrs"
)- AnonymousNot applicable