Forum Discussion
raf26
8 years agoNew Member
getting date for max value
Hi I am trying to get the date for a maximum value, I am using a groupby to get the maximum value from a table, then I would like to get the date where the maximum value was. Here is a secti...
- 8 years ago
No idea, it worked for me.
Greg_Deckler
Community Champion
8 years agoPerhaps something like:
Measure 6 = VAR myLocation = MAX(Table7[LOCATION]) VAR tmpTable = GROUPBY(Table7,Table7[LOCATION],"MaxTotal",MAXX(CURRENTGROUP(),[Totals])) VAR myMax = MAXX(tmpTable,[MaxTotal]) RETURN MAXX(FILTER(ALL(Table7),[LOCATION]=myLocation && [Totals]=myMax),[REPORT_DATE])
raf26
8 years agoNew Member
Many Thanks Greg, it is almost working but I think the issue is with
VAR myLocation = MAX(Table7[LOCATION])
This returns a number that I can't compared with my location on
RETURN MAXX(FILTER(ALL(Table7),[LOCATION]=myLocation && [Totals]=myMax),[REPORT_DATE])
But I think what I need to get is my location from my currentgroup
create here.
GROUPBY(Table7,Table7[LOCATION],"MaxTotal",MAXX(CURRENTGROUP(),[Totals]))
- Greg_Deckler8 years ago
Community Champion
No idea, it worked for me.
- raf268 years agoNew Member
Thanks, It worked, I had the wrong column name on the max statement.
Just one last question.
why this statement
MAX(Table7[LOCATION])
Location is a string, why we are doing a MAX on it.
- Greg_Deckler8 years ago
Community Champion
Have to use some sort of aggregation in measures. MAX or MIN would work, basically last or first.