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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gspollock
Helper I
Helper I

RANX gives results are inconsistent, don't match export and give duplicates

I am having several problems with a measure using RANKX.  This is the measure:

Rank Column = RANKX( ALLSELECTED(DIM_CUST_SLS_HIER[Account #]), FACT_SALES[FYTD GP TD],,DESC,Dense)

 

When the table has just the Rank Column measure and the columns that are used in the function, it is showing the same rank more than once in some cases.  For example here it has the 2nd ranked Account incorrectly showing as 3.

 

gspollock_0-1721940520808.png

A second issue is that the csv export doesn't show the same results as the visual.  For example account 55024511 is different between the two.    It is 40 in the table and 41 in the export. Account 20144705 is rank 55 in the visual and 54 in the export.

gspollock_1-1721941038663.png

 

Account #Rank ColumnFYTD GP TD
907314431                      8,411,069.86
37519623                      1,872,477.40
5758503                         670,648.16
3904294                         512,920.19
616586405                         481,438.49
5758356                         442,578.48
587860227                         434,445.96
605416218                         358,635.43
200133979                         327,711.49
383237610                         325,860.82
6065019111                         318,105.55
5436553712                         315,152.14
6173977013                         303,790.18
2009086114                         291,383.16
73321615                         276,359.18
6173976616                         263,645.34
5451318317                         259,155.80
430602618                         255,854.17
5441225919                         228,501.03
249121821                         225,174.51
5887669621                         226,095.96
5887675922                         218,998.72
6177209023                         217,463.57
5427179924                         214,085.70
6273477425                         213,866.53
5436344526                         213,138.24
5441140827                         211,371.54
2002908728                         204,764.02
215812429                         196,511.67
8704105230                         191,194.79
2001264631                         186,596.08
426807732                         185,596.40
6158800633                         163,433.92
374875434                         162,742.35
5887673636                         159,220.27
9320104136                         154,280.00
179280438                         153,271.99
2001992338                         152,431.58
2002906939                         151,745.48
374883041                         148,150.91
5502451141                         150,150.22
8207342                         144,111.60
425702544                         140,066.97
5426224844                         139,271.00
5732199045                         138,385.01
5691503646                         137,192.05
5983195547                         136,053.88
432244348                         130,930.79
2002910249                         130,540.97
5451135950                         129,189.70
2001753451                         128,149.80
7903024852                         127,513.98
431716653                         126,994.73
2014470554                         120,775.97
2002907255                         119,838.01

 

A third issue arises when new columns are introduced to the table, resulting in altered rankings. Furthermore, there are instances of duplicate rankings, which differ from those observed without the extra column. This occurs with the addition of either descriptive columns or additional measures. With each new column or measure incorporated, the rankings shift. The exported data displays rankings that vary from those seen in the table in each case.

gspollock_2-1721941503552.png

 

Thanks for any help you can offer.

2 REPLIES 2
Anonymous
Not applicable

Hi @gspollock ,

 

Here I create a easy sample to have a test. In my side, it could work. [Measure] is a easy sum measure.

vrzhoumsft_0-1721962857248.png

 

According to your statement, I think FACT_SALES[FYTD GP TD] is a measure. Your issue should be caused by this measure. Could you share a sample to show us your data model and your measure logic. 

This will make it easier for us to find the solution.

 

Best Regards,
Rico Zhou

 

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

This is the measure used in the rankx:

FYTD GP TD = var yr =
CALCULATE( MAX(DIM_PERIOD_GL_DATE[FISC_YR_NUM]), filter(all(DIM_PERIOD_GL_DATE),DIM_PERIOD_GL_DATE[Date] = TODAY()-1))
var res = CALCULATE([Sales GP AMT], filter(all(DIM_PERIOD_GL_DATE),DIM_PERIOD_GL_DATE[FISC_YR_NUM] = yr ))
return res

 

This is the Sales GP AMT measure:

Sales GP AMT = SUMX('DIM_OBI_GOV_CUST_SLS_HIER',CALCULATE(SUM(FACT_SLS[EXT_SELL_GP_AMT])))

 

As I mentioned, another oddity is that when we export we don't get the same results for the Rank Column as shown in the report.

 

I'm not sure what specifically you are looking for on the data model.  It has 18 tables.  Not all of them affect this particular result.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.