Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Ranking not consistent

Hi guys,    I need some help to understand where my measure goes wrong. I have sales data by brand and category and my ranking measure is made on a MAT measure basis. On top you see the category an...
  • TomasAndersson's avatar
    3 years ago

    Could it be that "Others" sometimes is the largest brand and therefore "takes up a spot" when you run Ranking ? 
    If so, you'd have to exclude "Others" from the table in the Ranking variable.

    What visual are you using to show the ranking? For bar charts for example, you can put a measure as a tooltip and then tell the visual to sort by the tooltip value. One way to sort by rank, but not sure if it applies to you.

  • TomasAndersson's avatar
    TomasAndersson
    3 years ago

    Great!

    I think you should be able to use the Alternate Result in SELECTEDVALUE() for that. This is probably not the most elegant solution (a lot of nested ifs), but it could hopefully help you get started.

    VAR __IsCategory = SELECTEDVALUE('Brand names'[Brand],"Category") 
    //If not a single Brand is selected, return "Category"


    //...and then


    VAR
     Result = 
    IF(__IsCategory="Category","",  //a new if clause. Return blank if "Category", and the rest as before
         if(IsotherSelected, ProductsToRank +
    1,
              IF ( Ranking <= ProductsToRank, Ranking, Ranking + 1)
         )
    )