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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
awilliams
Frequent Visitor

TopN error when trying to show ten rows in a table

Hi guys, 

 

Try = TOPN(10,ga1,ga1[Candidate Registrations], DESC)

 

May be a simple one here but im getting the following error when trying to use the TopN DAX expression to only show the first ten rows of a table: 

 

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

The syntax highlighter is not showing up any errors, so not sure why this won't work...

 

Excuse the simplicity as I am new to PowerBi and DAX, any help would be greatly appreciated!

 

Thanks

5 REPLIES 5
v-haibl-msft
Microsoft Employee
Microsoft Employee

@awilliams

 

TOPN returns the top N rows of the specified table. So you need to create a new table.

TopN error when trying to show ten rows in a table_1.jpg

 

Or you can sort the column of ga1[Candidate Registrations] and then keep bottom 10 rows in Query Editor.

TopN error when trying to show ten rows in a table_2.jpg

 

Best Regards,

Herbert

Thanks for your reply @v-haibl-msft. Unfortunately I don't want to remove rows from one column. I just simply want to show only the top ten results of a table, rather than the entire results.

@awilliams

 

If above resolutions are not you wanted, you can try add a rank column with following formula.

Rank = RANKX( gal, gal[Candidate Registrations])

TopN error when trying to show ten rows in a table_1.jpg

 

Then type the top number you wanted in visual level filter.

TopN error when trying to show ten rows in a table_2.jpg

 

Best Regards,

Herbert

Anonymous
Not applicable

So, you are writing a measure, and measures must always return a single (scalar) value.  TOPN( ) returns N rows... and you have not specified what you want to "happen" to those rows.

 

Something like   = CALCULATE( SUM(ga1[value]), TOPN(10, ga1, ga1[Reg], DESC) )  should do... something... I think? 🙂

 

Maybe easier to understand a   = IF (RANKX(ga1, ga1[Reg]) <= 10, [My Measure], BLANK() ) but should do the same.

 

Your formula would work if you use the "Calculate Table" function to create a brand new table of just the top 10, but that probably isn't what you want.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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