Forum Discussion

Carliniiiii's avatar
Carliniiiii
Frequent Visitor
2 years ago
Solved

Count by category

Hello Power BI community, 

 

I have following data set: 

ProjectLocation
Project1A
Project1A
Project1B
Project2B
Project2C

 

I would like to count each different location once per project. So I want to create a new table with following informations for further analysis: 

 

LocationFrequency
A1
B2
C1

 

Many thanks for your help or ideas. 

  • Carliniiiii , You can use Summarize function for this and create a new table by going into modelling section

     

    NewTable =
    SUMMARIZE(
    'YourTableName',
    'YourTableName'[Location],
    "Frequency", COUNTROWS(SUMMARIZE('YourTableName', 'YourTableName'[Project], 'YourTableName'[Location]))
    )

  • Carliniiiii , Create another table using

     

    GroupedData =
    SUMMARIZE(
    YourTableName,
    YourTableName[Location],
    YourTableName[Response],
    "Frequency", COUNT(YourTableName[Response])
    )

3 Replies

  • Carliniiiii , You can use Summarize function for this and create a new table by going into modelling section

     

    NewTable =
    SUMMARIZE(
    'YourTableName',
    'YourTableName'[Location],
    "Frequency", COUNTROWS(SUMMARIZE('YourTableName', 'YourTableName'[Project], 'YourTableName'[Location]))
    )

  • Carliniiiii's avatar
    Carliniiiii
    Frequent Visitor

    bhanu_gautam , I have another question in a similar format. 

     

    I have following table: 

     

    Location QuarterResponse
    AQ1Yes
    AQ2No
    AQ3No
    AQ4Yes
    BQ1No
    BQ2Yes
    BQ3Yes
    BQ4Yes

     

    And I would like it to be grouped by both location as well as yes/no answers. I have limited the example to one year only but it should work over multiple years.

     

    LocationsResponseFrequency
    AYes2
    ANo2
    BYes3
    BNo1

     

    Many thanks 

    • bhanu_gautam's avatar
      bhanu_gautam
      Super User

      Carliniiiii , Create another table using

       

      GroupedData =
      SUMMARIZE(
      YourTableName,
      YourTableName[Location],
      YourTableName[Response],
      "Frequency", COUNT(YourTableName[Response])
      )