Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi All,
I want to write a DAX expression to return the time from the maximum count of rows.
So as per below it would be 17:00.
My best attempt. This is returning the wrong answer at 19:00 currently
Solved! Go to Solution.
Try these measures. The concept is to rank [Count Rows] (a measure) in a virtual table, and then filter the virtual table for the top-ranked row.
Count Rows = COUNT ( 'Bike & Pedestrian Data'[ID] )
MaxTimeCount =
VAR vBaseTable =
ADDCOLUMNS (
SUMMARIZE (
'Bike & Pedestrian Data',
'Bike & Pedestrian Data'[TimeExtract (bins)],
'Bike & Pedestrian Data'[Transport Type]
),
"@CountRows", [Count Rows]
)
VAR vRankTable =
ADDCOLUMNS (
vBaseTable,
"@Rank", RANKX ( vBaseTable, [@CountRows],, DESC, DENSE )
)
VAR vTopRank =
FILTER ( vRankTable, [@Rank] = 1 )
VAR vResult =
MAXX ( vTopRank, 'Bike & Pedestrian Data'[TimeExtract (bins)] )
RETURN
vResult
Proud to be a Super User!
Worked a charm thank you very much
Try these measures. The concept is to rank [Count Rows] (a measure) in a virtual table, and then filter the virtual table for the top-ranked row.
Count Rows = COUNT ( 'Bike & Pedestrian Data'[ID] )
MaxTimeCount =
VAR vBaseTable =
ADDCOLUMNS (
SUMMARIZE (
'Bike & Pedestrian Data',
'Bike & Pedestrian Data'[TimeExtract (bins)],
'Bike & Pedestrian Data'[Transport Type]
),
"@CountRows", [Count Rows]
)
VAR vRankTable =
ADDCOLUMNS (
vBaseTable,
"@Rank", RANKX ( vBaseTable, [@CountRows],, DESC, DENSE )
)
VAR vTopRank =
FILTER ( vRankTable, [@Rank] = 1 )
VAR vResult =
MAXX ( vTopRank, 'Bike & Pedestrian Data'[TimeExtract (bins)] )
RETURN
vResult
Proud to be a Super User!
User | Count |
---|---|
97 | |
78 | |
77 | |
48 | |
26 |