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 moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello Experts,
I want to help me to write the DAX code to show only the TOP 10 Countries based on Revenue.
Solved! Go to Solution.
@Anonymous it should work :))
What is [Att_Value1]? Is that a column or a measure?
@Anonymous no worries 🙂
This is for the scenario where the total is for all (just change it to your names and 10 instead of 3):
Top 3 Countries By Sales =
VAR _countries = TOPN(3, ALLSELECTED(Customer[Country]),[Sales Amount])
RETURN
IF(
ISINSCOPE(Customer[Country]),
CALCULATE(
[Sales Amount],
KEEPFILTERS(_countries)
),
[Sales Amount]
)
@Anonymous
Top 10 Countries By Revenues =
VAR _top10_countries = TOPN(10, ALLSELECTED('Table'[Country]),[Revenues Measure])
RETURN
CALCULATE(
[Sales Amount],
KEEPFILTERS(_top10_countries)
)
@SpartaBI
its dose not worked,
see the right visual which I used a filter pane to show the top 10 countries.
In your code dax which is in left visual it dose give the top 10 countries and the numbers are nor correct.
@Anonymous what is the column you use in the matrix for country, and what ia the base measure?
its same, I know you sae different name in code and visual, but its same the coulm and measure.
@SpartaBI
@Anonymous it should work :))
What is [Att_Value1]? Is that a column or a measure?
Its worked. So Sorry I had a mistake. I will Accept your solurtions.
I have another Question:
If I want to show top 10 countries and show me the grand total of each country out of all countries ( I dont want to give the grand total of Top 10 countries only).
@Anonymous no worries 🙂
This is for the scenario where the total is for all (just change it to your names and 10 instead of 3):
Top 3 Countries By Sales =
VAR _countries = TOPN(3, ALLSELECTED(Customer[Country]),[Sales Amount])
RETURN
IF(
ISINSCOPE(Customer[Country]),
CALCULATE(
[Sales Amount],
KEEPFILTERS(_countries)
),
[Sales Amount]
)
Check out the April 2026 Power BI update to learn about new features.
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.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 22 | |
| 10 | |
| 10 | |
| 7 | |
| 5 |