Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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
TOPN returns the top N rows of the specified table. So you need to create a new table.
Or you can sort the column of ga1[Candidate Registrations] and then keep bottom 10 rows in Query Editor.
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.
I found this page particularly useful:
https://blogs.msdn.microsoft.com/danrub/2016/03/19/dynamic-topn-ranking-in-power-bi/
If above resolutions are not you wanted, you can try add a rank column with following formula.
Rank = RANKX( gal, gal[Candidate Registrations])
Then type the top number you wanted in visual level filter.
Best Regards,
Herbert
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.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 32 | |
| 27 | |
| 25 |