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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
gjohnson900
Helper I
Helper I

RANKX -- beginner trouble. Won't rank properly using ALLSELECTED. pics attached

I've got a pretty simple model, so I can't figure out why this isn't working for me...

 

The screen shots pretty much explain the issue. Trying to rank based on the [NumFolios] calculated measure.


There are slicers on the page, hence the ALLSELECTED. There are FILTERs applied as well... no blank zips.

 

Ultimately the OTA table will need to be excluded from the results, but I'm handling this in a filter right now as well.

 

[NumFolios] is a raw number coming through in a SQL query

 

 

formula.JPGgp_data.JPGsimple_model.JPGthe_gist.JPG

1 ACCEPTED SOLUTION
gjohnson900
Helper I
Helper I

Thanks for the pointers gang.  I ended up taking a slightly different approach.

 

Since the demograph table has 1 row per zip, I figured that was a good spot to put the ranking.

 

I first created a Calculated Measure in that table...

 

ZipTotalFolios = SUMX(RELATEDTABLE(GuestProfile), GuestProfile[NumFolios])

 

Then, I was able to rank on that, IN the demograph table again, using this...

demoRanker = RANKX(ALLSELECTED(Demograph), [ZipTotalFolios])

So far it's doing what I want, but I wish I understood what was causing the bad rankings before.

 

 

 

View solution in original post

3 REPLIES 3
gjohnson900
Helper I
Helper I

Thanks for the pointers gang.  I ended up taking a slightly different approach.

 

Since the demograph table has 1 row per zip, I figured that was a good spot to put the ranking.

 

I first created a Calculated Measure in that table...

 

ZipTotalFolios = SUMX(RELATEDTABLE(GuestProfile), GuestProfile[NumFolios])

 

Then, I was able to rank on that, IN the demograph table again, using this...

demoRanker = RANKX(ALLSELECTED(Demograph), [ZipTotalFolios])

So far it's doing what I want, but I wish I understood what was causing the bad rankings before.

 

 

 

v-juanli-msft
Community Support
Community Support

Hi @gjohnson900

When I use your dataset to apply the measure formula, I get this result. Does it meet your goal?

57.png

I wonder which columns add to slicers and filters and whether any other formula quotes the rank measure.

Best Regards

Maggie

Phil_Seamark
Employee
Employee

Hi @gjohnson900

 

How do you get on with this slightly different version

 

 

Ranker = 
	RANKX(
		ALL('GuestProfile'[Zip]) ,
		CALCULATE(
			SUM('GuestProfile'[NumFolios])
			)
	)

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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