Forum Discussion
slicing data by time
- 5 years ago
Hi, Laurence-
You can try to use the TIME() function to transform the max value of your time slicer, try a measure like this:
Numtotal = var _min=TIMEVALUE(MINX(ALLSELECTED('Time'),[Time])) var _max=TIMEVALUE(MAXX(ALLSELECTED('Time'),[Time])) var _max1=TIME(Hour(_max),0,0) return CALCULATE(COUNTROWS('uor_pbi-stumodules'),ALLSELECTED('uor_pbi-stumodules'),VALUES('uor_pbi-stumodules'[StudentId]),FILTER(('Events'),[Start Time]>=_min&&[End Time]<=_max1))More info about time() function in DAX
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Laurence-
According to your description, I think you can use this measure to get the total of student numbers based on the selection of your Time slicer, like this:
Num total =
var _min=MINX(ALLSELECTED('Time'),[Time])
var _max=MAXX(ALLSELECTED('Time'),[Time])
return
CALCULATE(SUM('Table'[NumStudents]),FILTER(ALL('Table'),[Start Time]<=_min&&[End Time]<=_max ))
Then you can create a Slicer using “List type” and select the max and min time manually because Power BI can’t support “Between” Slicer to display time:
And you can get what you want.
You can download my test pbix file here
If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.
How to Get Your Question Answered Quickly
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.