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

How to use GroupBy in a Measure

Hi All,

 

I am new to Power BI and trying to figure out how to accomplish a groupby as a measure. I know how to do it in the edit query section, but I don't want to alter the actual table. I have applications that have been categorized by type, datetime is noted and there are duplicates. What I am trying to accomplish is to group all of the unique applications by type and count how many were categorized per month. 

 

If someone could explain how to use groupby measure and how they would solve this problem that would be great. 

 

Something like.. ` test = GROUPBY( 'test application', 'test application' [type], "TypeCount", COUNTAX(currentgroup(), 'test application' [name]) 

 

This doesn't work and says that my expression refers to multiple columns, and that can't be converted to a scalar value. 

 

The solution doesn't have to be a group by if there is another way to solve this problem, but I would still like to know how to use it correctly in a measure because I can not get it to work. 

 

Thanks.

4 REPLIES 4
Greg_Deckler
Super User
Super User

I don't think you need GROUPBY, you can use SUMMARIZE but the issue you are probably having is that you have created this as a Measure versus a New Table. A measure needs a single value coming back but your formula returns a table of values.

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Okay I see what you are saying but I am still having a hard time recieving the counts for only unique applications. When I try and get the summary with both application type and date, the number of applictions is over double what it should be. It is as if the applictions from previous months are counted again in later months. 

 

`Table = SUMMARIZE('test application', 'test appliction'[date], 'test application'[type], "TypeCount", DISTINCTCOUNT('test application'[name]))

 

How can I go about getting just the distinct applications? So for each month how many apps were classified in those categories (ie. a running total) 

 

Thanks.

Going to need to see sample/example data.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Okay so might of been asking the wrong question. How then do I create a running sum of these values, or show the total number of that application type classified? I Only want the unique applications to count towards the application categorization total. The data contatins the application name, the date they were logged, the category they were classified in.

 

Here is a snap shot or my vis so far:

 

Screen Shot 2018-03-05 at 2.55.34 PM.png

As you can see there are two issues. The numbers don't sum to the total categorization count at the bottom. Also the count it not a running sum. 

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.