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
Anonymous
Not applicable

Getting the percentage of a name in a state

So I've been playing around with the USA Names dataset from BigQuery, and I've been trying to make a viz that shows the prevalence of a given name in each state (as in, the percentage of people having that name in that state over the total population of the state).

 

I'm still relatively new to Power BI so I still get a little confused when it comes to DAX, especially when it comes to measures like this where I get really confused when it comes to dealing with both a sum affected by a slicer and one relative to the whole table.

 

 

 

I wanna have a map like this, but instead of the total number of people, I'd get the percentage instead.

1.png

 

I tried creating a GroupBy table with the names and the states, and make the percentage a column instead, as follows, but it kept giving me weird values.

 

2.png

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

try Measure like this.

Measure = 
DIVIDE(
    COUNTROWS( 'Table' ),
    CALCULATE(
        COUNTROWS( 'Table' ),
        ALLEXCEPT( 'Table', 'Table'[Name] )
    )
)
 
image.png
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

try Measure like this.

Measure = 
DIVIDE(
    COUNTROWS( 'Table' ),
    CALCULATE(
        COUNTROWS( 'Table' ),
        ALLEXCEPT( 'Table', 'Table'[Name] )
    )
)
 
image.png
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

Anonymous
Not applicable

Hi @Mariusz

Edit: nevermind, I misinterpreted it, you are 100% right !

Hi @Anonymous 

 

My dataset.

image.png

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

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.