Forum Discussion

Renna's avatar
Renna
Frequent Visitor
2 years ago
Solved

Matrix Row Subtotal for Text as the most frequent values, instead of "First"

I have read many posts that mention similar topics, but they don't necessarily cover what I'm looking for. Usually, for text values in the Matrix, we only have options to display them as 'First', 'La...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Renna ,

    You can create a measure as below and replace the field [Project Manager] with this new measure.

    MProjectManager =
    VAR MaxCount =
        MAXX (
            VALUES ( 'Table'[Project Manager] ),
            CALCULATE ( COUNT ( 'Table'[Project Manager] ) )
        )
    VAR PMList =
        CONCATENATEX (
            FILTER (
                VALUES ( 'Table'[Project Manager] ),
                CALCULATE ( COUNT ( 'Table'[Project Manager] ) ) = MaxCount
            ),
            'Table'[Project Manager],
            ", "
        )
    VAR ProjectTypeTable =
        SUMMARIZE (
            'Table',
            'Table'[Project Types],
            'Table'[Project ID],
            'Table'[Project Manager]
        )
    VAR ModeValue =
        TOPN (
            1,
            ADDCOLUMNS (
                ProjectTypeTable,
                "SRevenue",
                    CALCULATE (
                        SUM ( 'Table'[Revenue] ),
                        ALLEXCEPT (
                            'Table',
                            'Table'[Project Manager],
                            'Table'[Project ID],
                            'Table'[Project Types]
                        )
                    )
            ),
            [SRevenue], DESC
        )
    RETURN
        IF (
            IFERROR ( SEARCH ( ",", PMList, 1, 0 ), 0 ) > 0,
            MAXX ( ModeValue, [Project Manager] ),
            PMList
        )

    Best Regards