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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NimaiAhluwalia
Responsive Resident
Responsive Resident

Top N dynamic and others

Hi, I need to create where I can show all countries whose percent reaches 80% which is RUSSIA in the below case and the rest of the countries below it should be shown in others.

 

NimaiAhluwalia_0-1626987383362.png

Data

 

CountryRank Sales cumulative Percent
 1  
US1   103,774,983,599.0040.48%
JAPAN2   123,583,832,903.0048.20%
CHINA3   143,194,182,989.0055.85%
GERMANY4   155,827,591,368.0060.78%
FRANCE5   164,516,421,698.0064.17%
ITALY6   172,651,060,426.0067.34%
UK7   179,731,952,617.0070.10%
SPAIN8   186,576,126,423.0072.77%
BRAZIL9   192,969,699,785.0075.26%
CANADA10   198,763,452,008.0077.52%
INDIA11   203,163,139,833.0079.24%
RUSSIA12   207,217,106,984.0080.82%
KOREA13   211,219,848,002.0082.38%
AUSTRALIA14   213,797,651,898.0083.39%
MEXICO15   216,031,838,455.0084.26%
POLAND16   218,175,441,462.0085.10%
ARGENTINA17   219,940,592,809.0085.78%
TURKEY18   221,702,844,090.0086.47%
SAUDI ARABIA19   223,405,987,034.0087.14%
SWITZERLAND20   225,102,062,850.0087.80%
TAIWAN21   226,763,849,208.0088.45%
BELGIUM22   228,411,087,629.0089.09%
AUSTRIA23   229,727,082,419.0089.60%
SWEDEN24   230,968,435,855.0090.09%
THAILAND25   232,143,312,908.0090.54%
PORTUGAL26   233,223,534,967.0090.97%
NETHERLANDS27   234,291,211,463.0091.38%
PHILIPPINES28   235,308,819,030.0091.78%
GREECE29   236,287,814,392.0092.16%
ROMANIA30   237,231,922,631.0092.53%
EGYPT31   238,147,091,877.0092.89%
SOUTH AFRICA32   239,054,048,331.0093.24%
PUERTO RICO33   239,896,394,781.0093.57%
CZECH REPUBLIC34   240,729,233,342.0093.89%
INDONESIA35   241,528,295,197.0094.20%
VIETNAM36   242,312,813,668.0094.51%
FINLAND37   243,086,251,381.0094.81%
BANGLADESH38   243,833,524,314.0095.10%
ALGERIA39   244,558,262,060.0095.39%
DENMARK40   245,271,848,147.0095.66%
IRELAND41   245,960,569,503.0095.93%
PAKISTAN42   246,638,479,919.0096.20%
NORWAY43   247,314,069,567.0096.46%
HUNGARY44   247,968,910,926.0096.72%
CENTRAL AMERICA45   248,609,165,531.0096.97%
BULGARIA46   249,129,928,422.0097.17%
CHILE47   249,622,441,793.0097.36%
ECUADOR48   250,039,376,094.0097.52%
HONG KONG49   250,451,293,490.0097.68%
UAE50   250,856,626,985.0097.84%
COLOMBIA51   251,260,699,514.0098.00%
SLOVAKIA52   251,640,973,404.0098.15%
FRENCH WEST AFRICA53   252,015,852,215.0098.29%
MOROCCO54   252,389,801,328.0098.44%
MALAYSIA55   252,734,017,630.0098.57%
CROATIA56   253,029,112,205.0098.69%
SERBIA57   253,317,383,052.0098.80%
KAZAKHSTAN58   253,591,424,387.0098.91%
NEW ZEALAND59   253,857,532,893.0099.01%
PERU60   254,104,207,364.0099.11%
DOMINICAN REPUBLIC61   254,348,006,382.0099.20%
LEBANON62   254,575,679,191.0099.29%
BELARUS63   254,795,756,910.0099.38%
SLOVENIA64   255,010,097,513.0099.46%
TUNISIA65   255,219,148,693.0099.54%
SINGAPORE66   255,414,945,634.0099.62%
LITHUANIA67   255,608,407,650.0099.70%
URUGUAY68   255,715,968,443.0099.74%
BOSNIA69   255,819,697,333.0099.78%
VENEZUELA70   255,911,140,291.0099.81%
LATVIA71   256,001,582,608.0099.85%
JORDAN72   256,089,541,889.0099.88%
ESTONIA73   256,170,546,289.0099.92%
KUWAIT74   256,250,105,125.0099.95%
SRI LANKA75   256,324,199,932.0099.98%
LUXEMBOURG76   256,388,112,703.00100.00%

 

 

Desired Output -  As soon as the Percent reaches 80 the below countries should be clubbed in the others with all their sales 

 

CountryRank Sales cumulative Percent
 1  
US1                           103,774,983,599.0040.48%
JAPAN2                           123,583,832,903.0048.20%
CHINA3                           143,194,182,989.0055.85%
GERMANY4                           155,827,591,368.0060.78%
FRANCE5                           164,516,421,698.0064.17%
ITALY6                           172,651,060,426.0067.34%
UK7                           179,731,952,617.0070.10%
SPAIN8                           186,576,126,423.0072.77%
BRAZIL9                           192,969,699,785.0075.26%
CANADA10                           198,763,452,008.0077.52%
INDIA11                           203,163,139,833.0079.24%
RUSSIA12                           207,217,106,984.0080.82%
Other13 Sum of all the other remaining countries 100.00%

 

@amitchandak 

@parry2k 
@Sean 
Can you help me in this!

12 REPLIES 12
v-yalanwu-msft
Community Support
Community Support

Hi, @NimaiAhluwalia ;

Please try new table:

Newtable = 
VAR _min =
    MINX ( FILTER ( 'EU', [Percent] > 0.8 ), [Percent] )
VAR _table=
   SUMMARIZE(FILTER('EU',[Percent]<=_min),[Country],"rank",[Rank],"rank cumulatie",[rank cumulatie],"percent",[Percent])
VAR _other =
    SUMMARIZE (
        'EU',
        "Country", "Other",
        "Rank",MINX ( FILTER ( 'EU', [Percent] > 0.8 ), [Rank] ) + 1,
        "Sales cumulative", SUMX ( FILTER ( 'EU', [Percent] > _min ), [rank cumulatie] ),
        "Percent", 1)
RETURN  UNION ( _table, _other )

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I tried this solution that gives me a static output in a table I need it dynamic as I need to filter those countries depending upon the product table so instead of creating a table we can create a measure which is dynamic in terms of products 

 

As in when I select any product I need to know which countries comes in the 80% and rest should show in the others.

tex628
Community Champion
Community Champion

Hi @NimaiAhluwalia , 

First of all you will need to add an "Other" to your Country table. You should be able to do this with a simple append. 


Next up regarding the calculation, try this:

Measure = 
SUMX( 
SUMMARIZE ( 'Country' , 
'Country' [Name] , 
"Value" , 
IF( 'Country'[Name] = "Other" , 
SUMX(
SUMMARIZE ( 'Country' , 
'Country' [Name] , 
"Value2" , IF( [Percent] >= 0,81 , [Sales comulative]
), [Value2] ) ,
IF( [Percent] < 0,81 , [Sales comulative] , BLANK() 
) , 
[Value]
)

 
Br, 
J


Connect on LinkedIn

@tex628 

 

Hope you are doing good can you help me with the below error

 

Regards

Hi @NimaiAhluwalia , 

Sorry for the delay, I'm on vacation ☀️

I made a few small misstakes so try this: 

Measure = 

SUMX( 
SUMMARIZE ( 'Country' , 
'Country' [Name] , 
"Value" , 
IF( 'Country'[Name] = "Other" , 
SUMX(
SUMMARIZE ( 'Country' , 
'Country' [Name] , 
"Value2" , IF( [Percent] >= 0,81 , [Sales comulative] )
), 
[Value2] 
) ,

IF( [Percent] < 0,81 , [Sales comulative] )
))
[Value]
)


Otherwise send the file and i can take a look directly! 

Br, 
J



Connect on LinkedIn

Hello @tex628 

 

I am getting the below error for the following solution

NimaiAhluwalia_0-1627334511565.png

 



v-yalanwu-msft
Community Support
Community Support

Hi, @NimaiAhluwalia ;

You could create a new table as follows:

Newtable =
VAR _min =
    MINX ( FILTER ( 'Table', [Percent] > 0.8 ), [Percent] )
VAR_table=
   SUMMARIZE(FILTER('Table',[Percent]<=_min),[Country],[Rank],[Sales cumulative],[Percent])
VAR _other =
    SUMMARIZE (
        'Table',
        "Country", "Other",
        "Rank",MINX ( FILTER ( 'Table', [Percent] > 0.8 ), [Rank] ) + 1,
        "Sales cumulative", SUMX ( FILTER ( 'Table', [Percent] > _min ), [Sales cumulative] ),
        "Percent", 1)
RETURN  UNION ( _table, _other )

The final output is shown below:

vyalanwumsft_0-1627275861985.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yalanwu-msft 

 

Thanks for your help the sample data which I had sent in the above post was extracted from a measure for the cumulative sales but I am not able to create the same in the calculated column and my whole solution is stuck due to that I am attaching a pbix file in the private chat have a look and let me know my mistake.

 

Regards

 

 

selimovd
Super User
Super User

Hey @NimaiAhluwalia ,

 

add a row with the country "Others" to your data source table.

Then the following measure should will give you the desired result:

Below 80 and Others = 
VAR vPercent = IF(MAX('DataTable'[Percent]) < 0.8, MAX('DataTable'[Percent]))
VAR vTableAbove80 =
    FILTER(
        ALL( 'DataTable' ),
        'DataTable'[Percent] >= 0.8
    )
RETURN
    IF(
        MAX( 'DataTable'[Country] ) = "Others",
        SUMX(
            vTableAbove80,
            'DataTable'[Percent]
        ),
        vPercent
    )

 

The same you can then do for the Sales, just change the column in the last SUMX from Percent to the Sales Column.

The result looks then like that:

selimovd_1-1626989382167.png

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Hey @selimovd 

 

Thanks for your response 

 

I am sending you the pbix file in Private Chat.

 

Regards,

 

Hey @NimaiAhluwalia ,

 

you didn't implement anything that I proposed. Where are you struggling?

 

Best regards

Denis

Opps I have sent you the wrong file apologies 

 

Regards,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.