Hi there,
I could really do with some help!
In Power BI Desktop, I would like to use the Sort by Column feature to re-arrange the order of one of the dimensions of my matrix table and associated 100% stacked column chart.
BEFORE:
Before using it, the data looks (correctly) like this.
It uses measures that, in the denominator (PWR), strips off the column filter using ALL() to derive the totals, as follows:
Percentage Attainment % = DIVIDE([PAC2],[PWR],0) PAC2 = IF(HASONEVALUE(AssessData[Term]) && HASONEVALUE(AssessData[Subject]) , CALCULATE(COUNTA(AssessData[Assessment]), AssessData[Assessment]<>"" ), 0 ) PWR = IF(HASONEVALUE(AssessData[Term]) && HASONEVALUE(AssessData[Subject]) , CALCULATE( COUNTA(AssessData[Assessment]), ALL(AssessData[PerCentAttainName]), AssessData[Assessment]<>"" ), 0 )
THEN:
However, I want to sort the Levels (Above, Below, Developing, etc) in non-alphabetical order and so I sorted the column 'PerCentAttainName' by another column 'PerCentAttainID'. These columns are calculated columns, picking up their values from a lookup table. PerCentAttainID holds integer values to organise the sort.
AFTER:
When I turn on the Sort By Column feature, it changes all the values to this (as if the ALL() function did not exist as the values in PWR denominator measure are the same as PAC2 numerator):
As you can see, the sort order is now as I would like, but the measure calculation has changed!
And then when I turn the Sort By Column feature off again, it reverts back to the correct sort order!
THOUGHTS:
I don't think the measures are wrong - ALL() should work this way, whether or not the column is sorted by another column or not. However, I am relatively new to DAX, so I could be fundamentally misunderstanding things.
I thought perhaps there was a bug in using RELATED(), so I populated the source table with actual data rather than looked-up data. Unfortunately I got the same behaviour.
Any help gratefully received! Thanks.