Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Summarized Table - Total By Column

Hi

I  need help to calculate (Total By Company) in my summary table , below is the code for the summarized table :

 

 

 

Summary Table = 
SUMMARIZE('Table1',
'Table1'[Company],
'Table1'[Type],
"TotalEmp",
DISTINCTCOUNT('Table1'[UserID])
)

 

 

 

 

below is the result of the above code :

CompanyTypeTotalEmp
ABCA15
XYZA23
ABCA34
XYZA410

 

The result I am looking for :

CompanyDivisionTotalEmpTotal By Company
ABCA159
XYZA2313
ABCA349
XYZA41013

 

Thanks

  • You want to do something like this:

    Summary Table = 
    ADDCOLUMNS (
        SUMMARIZE(
            'Table1',
            'Table1'[Company],
            'Table1'[Type]
        ),
        "Emp", CALCULATE ( DISTINCTCOUNT('Table1'[UserID]) ),
        "Total Company Emp ", CALCULATE ( DISTINCTCOUNT('Table1'[UserID]), ALLEXCEPT ( Table1, Table1[Company] ) )
    )

     

    You'll notice I've used SUMMARIZE in combination with ADDCOLUMNS rather than letting SUMMARIZE do the aggregation. Have a read of All The Secrets of Summarize 

6 Replies

  • bcdobbs's avatar
    bcdobbs
    Community Champion

    You want to do something like this:

    Summary Table = 
    ADDCOLUMNS (
        SUMMARIZE(
            'Table1',
            'Table1'[Company],
            'Table1'[Type]
        ),
        "Emp", CALCULATE ( DISTINCTCOUNT('Table1'[UserID]) ),
        "Total Company Emp ", CALCULATE ( DISTINCTCOUNT('Table1'[UserID]), ALLEXCEPT ( Table1, Table1[Company] ) )
    )

     

    You'll notice I've used SUMMARIZE in combination with ADDCOLUMNS rather than letting SUMMARIZE do the aggregation. Have a read of All The Secrets of Summarize 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Perfect , thanks for the support .

  • ALLUREAN's avatar
    ALLUREAN
    Solution Sage

    Hi, Anonymous 

     

    Try this:

    Summary Table =
    SUMMARIZE('Table1',
    'Table1'[Company],
    "TotalEmp",
    DISTINCTCOUNT('Table1'[UserID])
    )

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      This not what i am looking for , the column (Type) is missing .. I want the (Total By Company) grouped based on the company with (type) coulmn present in the table . 

      • bcdobbs's avatar
        bcdobbs
        Community Champion

        I think my suggestion does what you need.