Forum Discussion

chestercas's avatar
chestercas
Icon for Helper I rankHelper I
3 years ago
Solved

RANKX : different result on different graph

HI,


I don't understand what is happening with my RANKX function.
I rank different zone by result (different calcul).
I do a table (down) and a Card (Up).
On the exemple, we can see all the results are right (on the left). Zone "SUD EST" is 5th.
But on the right, the table told me SUD EST is 1st, and the card graph told me 2nd... It's the same measure...
All the filters are right.
There is my RANKX measure : 

Rank prod = RANKX(FILTER(ALL(DATA_BRMC[Zone]),DATA_BRMC[Zone]="AG IDF" || DATA_BRMC[Zone]="AG NORD EST" || DATA_BRMC[Zone]="AG OUEST" || DATA_BRMC[Zone]="AG SUD EST" || DATA_BRMC[Zone]="AG SUD OUEST"),[Prod / h log])
I have 5 graph with different calcul (based on the same measure for rank). 2 are false and 3 are right.
I can't explain why... And I tried many things...

Can you help me ?

Thanks a lot,
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi chestercas ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data. 

    (2) We can create a measure. 

    Rank prod = 
    var _a=RANKX(ALL('DATA_BRMC'),'DATA_BRMC'[Prod/h log],MAX('DATA_BRMC'[Prod/h log]),DESC,Dense)
    var _b=IF(ISFILTERED('DATA_BRMC'[Zone]),_a,BLANK())
    return _b

    (3) Then the result is as follows.

    Note that this measure needs to be used with slicers when placed on a card visual, and if you only want to show the rank of [AG SUD EST], create a measure like the following and place it on the card visual.

    AG SUD EST rank = CALCULATE('DATA_BRMC'[Rank prod],FILTER(ALL('DATA_BRMC'),'DATA_BRMC'[Zone]="AG SUD EST"))

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

2 Replies

  • I analysed my database, and I think the filter on measure is not apply (it add the "no ref" value").
    I tried to change "rank prod" measure, but not working... 😞


    Thx

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi chestercas ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) This is my test data. 

    (2) We can create a measure. 

    Rank prod = 
    var _a=RANKX(ALL('DATA_BRMC'),'DATA_BRMC'[Prod/h log],MAX('DATA_BRMC'[Prod/h log]),DESC,Dense)
    var _b=IF(ISFILTERED('DATA_BRMC'[Zone]),_a,BLANK())
    return _b

    (3) Then the result is as follows.

    Note that this measure needs to be used with slicers when placed on a card visual, and if you only want to show the rank of [AG SUD EST], create a measure like the following and place it on the card visual.

    AG SUD EST rank = CALCULATE('DATA_BRMC'[Rank prod],FILTER(ALL('DATA_BRMC'),'DATA_BRMC'[Zone]="AG SUD EST"))

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.