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
CBahnsen
Regular Visitor

counts by zip code

I'm just getting started with Power BI.  I wrote a simple sql query and used it in a DirectQuery, thinking l could do a number of different aggregations on the raw dataset in Power BI itself.

 

Here's what some of the query results look like:

sqlQueryResults08312020.JPG

 

In the Power BI model window I gave the PatZip a Data category of Postal Code and in a table it's grouping and sorting by zip code.

zipCodesAreSorted08312020.JPG

 

But I can't figure out how to get counts by zip code.  I'll want to perform similar counts on the other categories, viz., PatStatus, PatAge, and PatSex.

 

Thanks for any help.

 

Christian Bahnsen

1 ACCEPTED SOLUTION
fhill
Resident Rockstar
Resident Rockstar

Drag ZIP to the Table a 2nd time, and then under Values, drop down and change it to Count....

 

fhill_0-1598899676176.png

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

5 REPLIES 5
fhill
Resident Rockstar
Resident Rockstar

Drag ZIP to the Table a 2nd time, and then under Values, drop down and change it to Count....

 

fhill_0-1598899676176.png

 




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




@fhill  Thanks ... I never would have thought of doing it that way.  I was trying to do a calculated column or create a measure or something along those lines

Tahreem24
Super User
Super User

As I'm not aware of the data model so you can try a below Dax :

ZipCode Count = CALCULATE( COUNT(Table[ZipCode Column ]), ALLEXCEPT(Table, AgeColumn))

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

@CBahnsen , not very clear. You can take a count of column.

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

 

@amitchandak  I want counts by each zip code (or sex or whatever category I choose), not a count of all the zip codes.

 

Here's how I'd do it in ssms

groupZip08312020.JPG

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.