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
DAXUser
Frequent Visitor

Previous 2 year values for current top 7 countries and others

I want to show the sales of TOP 7 countries for the selected year and the remaining sales I need to add up the country and show it as "Other" in Country Name column. After that, Based on current top 7 countries names i need to compare with previous last two years same country sales amount.

 

CalendarCountry      NameTotal
2024Qatar18.98
2024Australia15.28
2024Malaysia12.2
2024UK9.64
2024United States4.56
2024Netherlands3.32
2024Canada1.28
2024Others17.4

 

Expected Ouput: Comparing current top 7 countries with previous year

CalendarCountry NameTotal
2024Qatar18.98
2024Australia15.28
2024Malaysia12.2
2024UK9.64
2024United States4.56
2024Netherlands3.32
2024Canada1.28
2024Others17.4
2023Qatar20.98
2023Australia17.28
2023Malaysia16.2
2023UK10.64
2023United States9.56
2023Netherlands8.32
2023Canada6.28
2023Others19.4
2022Qatar22.98
2022Australia17.98
2022Malaysia13.2
2022UK11.64
2022United States10.56
2022Netherlands9.32
2022Canada7.28
2022Others19.76

 

Measure used:
 
Total Sales =
 
VAR _start= Year(MAX ( 'Calendar'[Date] )) 
VAR _end = _start - 2
 
 
 
    CALCULATE (
  ROUND(  CALCULATE(Sales amount),2),
                  ALL ( 'Calendar' ),
                  FILTER (
                            'DATE',
                            year('DATE'[DATE_TIMESTAMP_DTM])     <= _start
                             && year('DATE'[DATE_TIMESTAMP_DTM]) >= _end
                         )
             )
 

This measure i used to calculate top 7 and others, and also to display last 2 year sales value comparsion with current year sales values of the top 7 countries

Top7=
VAR Top_N = 7

VAR TOPNCOUNTRY = TOPN(Top_N,
ALL('COUNTRY'),
[Total Sales]
)

VAR ALLCOUNTRY = CALCULATE( [Total Sales],ALLSELECTED('COUNTRY'))

VAR OTHERCOUNTRY = ALLCOUNTRY - CALCULATE( [Total Sales,TOPNCOUNTRY)

VAR TOPNCOUNTRYDIS = CALCULATE( [Total Sales],KEEPFILTERS(TOPNCOUNTRY))

VAR CURRENTPCOUNTRY = SELECTEDVALUE('INTENSITY COUNTRY'[COUNTRY])

RETURN
IF( CURRENTPCOUNTRY = "Others",
OTHERCOUNTRY,
TOPNCOUNTRYDIS
)

 

Problem:
Previous year values for current top 7 countries name is not happening instead each year it displays top 7 and others

1 REPLY 1
lbendlin
Super User
Super User

As long as you are fully aware that the Top 7 of the current year may not even exist in the prior year (which makes the comparison questionable) this is a straight forward process.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

 

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.