Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Rankx not working as expected with negatives values

Hello 🙂

 

I'm working with the Rankx function to rank stores by marge but it's jump by one when i have a negative value, exemple :

NB : the column Store from the table T_Stores and the measure Marge from another table T_Sales.

 

Store            Marge          Rank

A                      50 %               1

B                      26 %               2

C                      18 %               3

D                   - 12%                5

E                    - 8 %                  6

 

My formula is : 

 

10 REPLIES 10
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

could you share a screenshot of your data model?

 

Regards,

Marcus

Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Anonymous
Not applicable

Hello @mwegener , thank you for your response but i'm sorry i can't share the data model it's large and for confidentiality reason

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

however, you must at least describe your existing measure and how the columns & tables are related so that help can be provided.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Anonymous
Not applicable

@mwegener 

 

I have two tables 'CA'  and  'Point de vente' with cardinality (*:1) to the CA table which contain the CA_TTC measure.

 

CA__TTC = Sum(MNT_TTC)

 

CA                                                     Point de vente

Id_PDV   (*)  <---------------------   (1) Id_PDV

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,


is your problem solved?
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


mwegener
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

try this

RanK = RANKX(ALLSELECTED('Point de vente'[Code Point de vente]);[CA__TTC];;DESC;Dense)

 

I think "id_PDV" and "Code Point de vente" have a *: 1 relationship

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


amitchandak
Super User
Super User

Refer

https://community.powerbi.com/t5/Desktop/wrong-rank-in-negative-values/td-p/262113

https://community.powerbi.com/t5/Desktop/RankX-how-to-solve-when-I-do-have-negative-numbers-and-I-wa...

 

or try like

 

Rank = RANKX(ALLSELECTED(store),[Marge],,ASC,Dense)

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hello @amitchandak , i tested your formula and i got this !Pbix.PNG

Anonymous
Not applicable

My formula is : RANKX(ALL(T_STORES);T_SALES[Marge];;;Dense)

Anonymous
Not applicable

I'm not sure I follow exactly but using this formula is working fine for me...

 

RANK = RANKX('Table', 'Table'[MARGE])
 
rank.PNG

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.