You can use color by measure, but it gives you pre defined colors. If you use if statements and color codes the transitions between the colors won't be that sequencial.
To help users find verified answers, please don't forget to mark a correct resolution or answer to your problem or question as correct.