This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I have a table
Project ID Country Values CountryCode
P111 America 126 A
P111 America 222 A
P111 UK 572 U
P111 UK 36 U
P111 Brazil 665 B
P111 France 13 F
P222 America 987 A
P222 Spain 65 S
P222 Italy 77 I
P222 Italy 364 I
P222 Germany 15 G
P333 UK 872 U
P333 UK 562 U
P333 Spain 212 S
And I need this
Project ID Country Sum of Values Codes
P111 Brazil 665 B U A
P111 UK 608 B U A
P111 America 348 B U A
P222 America 987 A I S
P222 Italy 441 A I S
P222 Spain 65 A I S
P333 UK 1434 U S
P333 Spain 212 US
I tried use this DAX code
Codes = CONCATENATEX (
FILTER (
SUMMARIZE ( 'Table1'; 'Table1'[Project ID]; [CountryCode] );
[Project ID] = EARLIER ( 'Table1'[Project ID] )
);
'Table1'[CountryCode];
" "
)
but it concatenates all codes not only top 3.
Thanks for help I would appreciate any Idea.
zkrl
Solved! Go to Solution.
Hi @zkrl,
There are two solutions as a calculated column and a measure. Please give it a try.
Calculated Column =
CALCULATE (
CONCATENATEX (
TOPN (
3,
SUMMARIZE (
'Table1',
Table1[Project ID],
Table1[Country],
'Table1'[CountryCode],
"total", SUM ( Table1[Values] )
),
[total], DESC
),
[CountryCode],
"-",
[total], DESC
),
ALLEXCEPT ( Table1, Table1[Project ID] )
)
Measure Codes =
CALCULATE (
CONCATENATEX (
TOPN (
3,
SUMMARIZE (
'Table1',
Table1[Project ID],
Table1[Country],
'Table1'[CountryCode],
"total", SUM ( Table1[Values] )
),
[total], DESC
),
[CountryCode],
"-",
[total], DESC
)
)
Best Regards,
Dale
Hi @zkrl,
Try this formula please. And check out the attached demo.
One precondition: One country only has one CountryCode.
Measure Codes =
CALCULATE (
CONCATENATEX (
TOPN (
3;
SUMMARIZE (
'Table1';
Table1[Project ID];
Table1[Country];
"CountryCode"; IF (
ISBLANK ( MIN ( 'Table1'[CountryCode] ) );
"-";
MIN ( 'Table1'[CountryCode] )
);
"total"; SUM ( Table1[Values] )
);
[total]; DESC
);
[CountryCode];
" ";
[total]; DESC
)
)
Best Regards,
Dale
Thank you v-jiascu-msft it works, but I have a problem with the blank values in CountryCode. I edited the code.
TOP3Codes = CALCULATE (
CONCATENATEX (
TOPN (
3;
SUMMARIZE (
'CompressedData';
CompressedData[Project ID];
CompressedData[Master CCtr Name];
CompressedData[Main Discipline];
"total"; SUM ( CompressedData[Approved Hours] )
);
[total]; DESC
);
IF(ISBLANK(CompressedData[Main Discipline]); " - "; [Main Discipline]);
" ";
[total]; DESC
);
ALLEXCEPT ( CompressedData; CompressedData[Project ID] )
)
Sometimes it shows top 3 codes even with this - sign as a blank but sometimes not. It skips the blanks. For example
Project ID Country Values CountryCode
P111 America 126 A
P111 America 222 A
P111 UK 572 U
P111 UK 36 U
P111 Brazil 665
P111 France 13 F
Should be like this
Project ID Country Sum of Values Codes
P111 Brazil 665 - U A
P111 UK 608 - U A
P111 America 348 - U A
But shows me this
Project ID Country Sum of Values Codes
P111 UK 608 U A F
P111 America 348 U A F
P111 France 13 U A F
Thanks for help
zkrl
Hi @zkrl,
Try this formula please. And check out the attached demo.
One precondition: One country only has one CountryCode.
Measure Codes =
CALCULATE (
CONCATENATEX (
TOPN (
3;
SUMMARIZE (
'Table1';
Table1[Project ID];
Table1[Country];
"CountryCode"; IF (
ISBLANK ( MIN ( 'Table1'[CountryCode] ) );
"-";
MIN ( 'Table1'[CountryCode] )
);
"total"; SUM ( Table1[Values] )
);
[total]; DESC
);
[CountryCode];
" ";
[total]; DESC
)
)
Best Regards,
Dale
Thank you for the help.
zkrl
Hi @zkrl,
There are two solutions as a calculated column and a measure. Please give it a try.
Calculated Column =
CALCULATE (
CONCATENATEX (
TOPN (
3,
SUMMARIZE (
'Table1',
Table1[Project ID],
Table1[Country],
'Table1'[CountryCode],
"total", SUM ( Table1[Values] )
),
[total], DESC
),
[CountryCode],
"-",
[total], DESC
),
ALLEXCEPT ( Table1, Table1[Project ID] )
)
Measure Codes =
CALCULATE (
CONCATENATEX (
TOPN (
3,
SUMMARIZE (
'Table1',
Table1[Project ID],
Table1[Country],
'Table1'[CountryCode],
"total", SUM ( Table1[Values] )
),
[total], DESC
),
[CountryCode],
"-",
[total], DESC
)
)
Best Regards,
Dale
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 35 | |
| 32 | |
| 25 | |
| 22 | |
| 18 |
| User | Count |
|---|---|
| 65 | |
| 35 | |
| 32 | |
| 25 | |
| 23 |