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
mrclay82
Helper II
Helper II

Group data by country

Hi,

 

I have some sales data per country that I want to show.

 

But for some countries, I want to group the result.

So if the country is Belgium, Netherlands or Luxembourg the result should show as “Benelux”.

The only requirement is that I need to create a measure, and not a calculated column to achieve this.

 

From this:            

               

Country               Sales amount

Germany               5

Belgium                3

Luxembourg         2

Netherlands          3

 

 

To this:

Country               Sales amount

Germany               5

Benelux                 8

Thanks!

8 REPLIES 8
tamerj1
Super User
Super User

Hi @mrclay82 
You can creat a new calculated column (Country New) with IF statment Like

IF ( 'Table'[Country] IN { "Belgium", "Netherlands", "Luxembourg" }, "Benelux", 'Table'[Country] )
Then use the new Country column in the visual.

Hey @tamerj1 !
You have helped me before 🙂
Unfortunatelly I'm restricted to only use a measure to solve this, not a calculated column.
Could you please advise? 🙂

Br

@mrclay82 
Yes, but you still can locally create a a disconnected table (Countries) that contains all countries but replacing "Belgium", "Netherlands" and "Luxembourg" with “Benelux”. Use this coulm in the table visual along with the following measure

=
SUMX (
    VALUES ( Countries[Country] ),
    IF (
        Countries[Country] = "Benelux",
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            'Table'[Country] IN { "Belgium", "Netherlands", "Luxembourg" }
        ),
        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Country] = Countries[Country] )
    )
)

No I can't:

mrclay82_1-1685695826228.png

I need to solve this with a measure only somehow.

@mrclay82 
Then the only solution is ask the data owner to add the column for you.

Aren't there any table manipulating function I can use to nest in a measure?

@mrclay82 
Of course there are. But that won't get you anywhere. You need a column to slice by in a ny visual. You cannot slice by a measure. This is how Power Bi functions.

some_bih
Super User
Super User

Hi @mrclay82 your measure should be Sales = SUM(YourTableName[Sales amount])

YourTableName - is simply your table name. I hope this help





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






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.