If you want to Sort the Revenue before you TAKE the first 10 items:
=LET(rev_filter, --(Revenue[Top Product]=$C$66)*(Revenue[Location]=$C$67)),
rev_column, HSTACK(CHOOSECOLS(Revenue, 1, 2, 17), Revenue[FY24 Revenue]),
rev_filter, FILTER(rev_column, ref_filter>0),
rev_sorted, SORT(rev_filter, 4, -1),
TAKE(rev_sorted, 10, 3)
)
If you want to Sort the Revenue after you TAKE the first 10 items:
=LET(rev_filter, --(Revenue[Top Product]=$C$66)*(Revenue[Location]=$C$67)),
rev_column, HSTACK(CHOOSECOLS(Revenue, 1, 2, 17), Revenue[FY24 Revenue]),
rev_filter, FILTER(rev_column, ref_filter>0),
rev_sorted, SORT(TAKE(rev_filter, 10), 4, -1),
DROP(rev_sorted, , -1)
)
Note that an important step here is to include the Sort column in the data that you FILTER, so that it all still matches up, and then discard it before returning the results.
Why 2 versions? Consider the following table:
| Value1 |
Value 2 |
| A |
1 |
| B |
4 |
| C |
2 |
| D |
3 |
If you TAKE the top 3 rows, and then sort it on Value 2, you get this result:
| Value1 |
Value 2 |
| A |
1 |
| C |
2 |
| B |
4 |
However, if you sort it on Value 2, and then TAKE the top 3 rows, you get this result instead:
| Value1 |
Value 2 |
| A |
1 |
| C |
2 |
| D |
3 |
CHOOSECOLS()resulting which is theRevenue[FY24 Revenue]col could you let us know as well.TAKEthe first 10 rows, or after youTAKEthe first 10 rows? These can each give very different results, and will therefore change whetherSORTBYgoes inside theTAKE, or outside theTAKE(which would also require you toTAKE(Revenue[FY24 Revenue],10)for your sortby). Really, you might want to look into using aLETto break things down into clearer steps too.RevenuewithSORTBY(Revenue,Revenue[FY24 Revenue],-1).