Forum Discussion

mlim0806's avatar
mlim0806
Frequent Visitor
2 years ago
Solved

Create one table with split columns for each field values

Hi Community, 

 

I'm trying to create a table that displays the count of people within the three categories (gender, ETNY, and travel) within each city. How I achieve this in excel is a trick creating a separate pivot table for each category and simply hiding the repeated columns giving the illusion of one table.

 

The issue with the matrix table in pbi is that it layers on these different field values rather than keeping them separate. 

 

Input data:

CityGenderETNYTravelPerson ID
OrlandoMaleBLYes1
MiamiMaleHIYes2
New YorkFemaleINYes3
DCMaleASYes4
DCFemaleBLNo5
DCFemaleHIYes6
New YorkFemaleINNo7
HoustonFemaleASYes8
DCFemaleBLYes9
New YorkMaleHINo10
HoustonFemaleINNo11
MiamiFemaleASYes12
New YorkMaleBLNo13
OrlandoFemaleHIYes14
OrlandoMaleINYes15
OrlandoFemaleASNo16

 

Desired output:

 GenderETNYTravel 
CityFemaleMaleASBLHIINNoYesTotal number of Person IDs
DC31121 134
Houston2 1  1112
Miami111 1  22
New York22 112314
Orlando221111134
Grand Total106444461016
  • Hi mlim0806, give these a try, and if you run into any issues, let me know.

    Measures:

    Female Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Gender] = "Female")
    Male Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Gender] = "Male")
    AS Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "AS")
    BL Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "BL")
    HI Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "HI")
    IN Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "IN")
    Yes Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Travel] = "Yes")
    No Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Travel] = "No")

    use the measures to create a summary table in a matrix visual:
    Drag City to Rows.

    Drag Female Count, Male Count, AS Count, BL Count, HI Count, IN Count, No Count, Yes Count, to Values in the matrix.
    add another measuer:

    Total Persons = COUNT('Table'[Person ID])


     

4 Replies

  • ahadkarimi's avatar
    ahadkarimi
    Solution Specialist

    Hi mlim0806, give these a try, and if you run into any issues, let me know.

    Measures:

    Female Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Gender] = "Female")
    Male Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Gender] = "Male")
    AS Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "AS")
    BL Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "BL")
    HI Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "HI")
    IN Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[ETNY] = "IN")
    Yes Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Travel] = "Yes")
    No Count = 
    CALCULATE(COUNT('Table'[Person ID]), 'Table'[Travel] = "No")

    use the measures to create a summary table in a matrix visual:
    Drag City to Rows.

    Drag Female Count, Male Count, AS Count, BL Count, HI Count, IN Count, No Count, Yes Count, to Values in the matrix.
    add another measuer:

    Total Persons = COUNT('Table'[Person ID])