Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
97 | |
69 | |
46 | |
39 | |
33 |
User | Count |
---|---|
163 | |
110 | |
61 | |
51 | |
40 |