March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all, I encounter a question about calculating the sum in a special time span.
Here is a part of the table.
How to filter the time from yesterday 23:00 to the next day 6:00?
The DATESBETWEEN function returns a table of dates, but not the hours.
Solved! Go to Solution.
@Bridge2022 , Assume you have selected date of date in context
Measure =
var _sel = maxx(allselected('Date'), Date[Date])
var _min=_sel-1 + time(23,0,0)
var _max_sel + time(6,0,0)
return
calculate(sum(Table[Value]), filter(Table, Table[Date] >= _min &&Table[Date]<=_max))
or create a date only column in your table and use that
new column
Date1 = datevalues([Date])
Measure =
var _sel = maxx(allselected('Table'), Table[Date1])
var _min=_sel-1 + time(23,0,0)
var _max_sel + time(6,0,0)
return
calculate(sum(Table[Value]), filter(Table, Table[Date] >= _min &&Table[Date]<=_max))
Thanks for your help. 😀
I will try it tommorrow.
@Bridge2022 Try:
Measure =
VAR __Today = TODAY()
VAR __Yesterday = __Today - 1
VAR __Start = __Yesterday + TIME(23,0,0)
VAR __End = __Start + 7/24
RETURN
SUMX(FILTER('Table',[Date]>=__Start && [Date]<=__End),[Sales])
@Bridge2022 , Assume you have selected date of date in context
Measure =
var _sel = maxx(allselected('Date'), Date[Date])
var _min=_sel-1 + time(23,0,0)
var _max_sel + time(6,0,0)
return
calculate(sum(Table[Value]), filter(Table, Table[Date] >= _min &&Table[Date]<=_max))
or create a date only column in your table and use that
new column
Date1 = datevalues([Date])
Measure =
var _sel = maxx(allselected('Table'), Table[Date1])
var _min=_sel-1 + time(23,0,0)
var _max_sel + time(6,0,0)
return
calculate(sum(Table[Value]), filter(Table, Table[Date] >= _min &&Table[Date]<=_max))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |