cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MarkLaf Member
Member

Re: How do I return a calculated table sorted by a specific column?

Why not use a measure?

 

Max % Sector = CALCULATE(VALUES(TableSummaries[Sector]),TOPN(1,FILTER(ALL(TableSummaries),TableSummaries[Percentage]=CALCULATE(MAX(TableSummaries[Percentage]),ALL(TableSummaries)))))

 

Or avoid relying on a calculated column and just go with the following (LASTNONBLANK+TOPN lifted from yet another great SQLBI article):

Perc = SUMX(TableSummaries,SUM(TableSummaries[Counts])/SUM(TableSummaries[Base]))
Max % Sector NoCC = CALCULATE(LASTNONBLANK(TOPN(1,VALUES(TableSummaries[Sector]),[Perc]),1),ALL(TableSummaries))