Forum Discussion
Anonymous
11 months agoNot applicable
Max value with a subcategory
Hello. I have data that looks like the data inserted below. I am trying to sum the enrollment on the 2nd largest begin date for each ag_level. For example (using the data sample below), for ag_...
- 11 months ago
Anonymous
you can create a calculated column
column=var _max=CALCULATE(max('Table'[begin date]),ALLEXCEPT('Table','Table'[ag_level]))return if('Table'[begin date]=maxx(FILTER('Table','Table'[ag_level]=EARLIER('Table'[ag_level])&&'Table'[begin date]<_max),'Table'[begin date]),1)filter the column to 1, then no matter you choose daily or weekly , it will only show the data that you want. - 11 months ago
Hi Anonymous
Try the following measures:
All Second Highest Dates = VAR _perPartition = SUMX ( VALUES ( 'Table'[ag_level] ), VAR _secondDate = MAXX ( INDEX ( 2, ALL ( 'Table'[ag_level], 'Table'[begin date] ), ORDERBY ( [begin date], DESC ), , PARTITIONBY ( 'Table'[ag_level] ) ), [begin date] ) RETURN SUMX ( FILTER ( 'Table', 'Table'[begin date] = _secondDate ), 'Table'[enrolled_count] ) ) RETURN _perPartitionDaily Second Highest Dates = VAR _perPartition = SUMX ( VALUES ( 'Table'[ag_level] ), VAR _secondDate = MAXX ( INDEX ( 2, ALL ( 'Table'[ag_level], 'Table'[begin date] ), ORDERBY ( [begin date], DESC ), , PARTITIONBY ( 'Table'[ag_level] ) ), [begin date] ) RETURN SUMX ( FILTER ( 'Table', 'Table'[begin date] = _secondDate && 'Table'[ag_level] = "Daily" ), 'Table'[enrolled_count] ) ) RETURN _perPartitionWeekly Second Highest Dates = VAR _perPartition = SUMX ( VALUES ( 'Table'[ag_level] ), VAR _secondDate = MAXX ( INDEX ( 2, ALL ( 'Table'[ag_level], 'Table'[begin date] ), ORDERBY ( [begin date], DESC ), , PARTITIONBY ( 'Table'[ag_level] ) ), [begin date] ) RETURN SUMX ( FILTER ( 'Table', 'Table'[begin date] = _secondDate && 'Table'[ag_level] = "Weekly" ), 'Table'[enrolled_count] ) ) RETURN _perPartitionDetails are in the attached pbix
Anonymous
10 months agoNot applicable
Hi Anonymous ,
Just checking in were you able to test danextian’s DAX measures for the 2nd latest Daily and Weekly enrollments?
Curious to know if they’re now returning the correct “Yesterday” and “Last Week” results in your visuals.
Thanks,
Akhil.