'PowerBI Product ranking by Business, Dept, Category and Sub Category

I am trying to rank products by different hierarchies but when I put them in a visual they don't look right. I have attached picture of my sample data and what i want to achieve.

I want all 4 ranks on powerbi visual like highlighted in yellow but when i add dept, category and sub category to visual it all changes 1.

Dept Rank = RANKX(ALLSELECTED(Query1[Department]),CALCULATE(SUM(Query1[Sale$])),,DESC,Dense)

CategoryRank = RANKX(ALLSELECTED(Query1[Category]),CALCULATE(SUM(Query1[Sale$])),,DESC,Dense)

Business Rank = CALCULATE(RANKX(ALL(Query1[ISC]),[Sales Amount],,DESC))

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source