Forum Discussion
DAX - Getting Earliest Date Time
- 2 years ago
Most likely your column is formatted as text rather than DateTime.
lbendlinthe column is formatted as General Date
*3/14/2001 1:30:55 PM (General Date)
- lbendlin2 years agoSuper User
- Anonymous_2262 years agoFrequent Visitor
lbendlini took a look at your pbix and formating the column as earliest would work there but for my case i have to use a measure and accomplish this in DAX. I am connected Direct Query to dataset i am limited to DAX measures only. Do you have any other suggestions?
I have gotten close with this measure i have:VAR StartTimesAsInteger =
ADDCOLUMNS(
FILTER(
SomeOtherTable,
SomeOtherTable[Value] = "Group 1"
),
"StartInteger",
YEAR(SomeOtherTable[Start]) * 10000000000 +
MONTH(SomeOtherTable[Start]) * 100000000 +
DAY(SomeOtherTable) * 1000000 +
HOUR(SomeOtherTable) * 10000 +
MINUTE(SomeOtherTable) * 100 +
SECOND(SomeOtherTable),
"UniqueKey",
SomeOtherTable[Number] & "|" & "Group 1"
)VAR RankedStartTimes =
ADDCOLUMNS(
StartTimesAsInteger,
"Rank",
RANKX(
FILTER(
StartTimesAsInteger,
[UniqueKey] = EARLIER([UniqueKey])
),
[StartInteger],
,
ASC,
Dense
)
)
VAR EarliestStartTimes =
FILTER(
RankedStartTimes,
[Rank] = 1
)
RETURN COUNTROWS(EarliestStartTimes)
In this example i have 2 entries for group 1 that have the same number in the number column but i cant get the measure to return me the row with the earliest start time.- lbendlin2 years agoSuper User