Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

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

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    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.

     

     

    • Anonymous's avatar
      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.