it appears to be semi-random, actually. Most of the time it goes material (up to max), then count), then quality last. But, at other times, it seems to go totally random. Perhaps material change is the highest probability, and that paired with the RNG streak tendencies makes it seem more common than it is (after all, you can only change quality once, and count 1-2 times, when there can be 8 material upgrades)
IF there's a rhyme or reason for the differences, I've not seen it yet.