Forum Discussion

chirag_usf's avatar
chirag_usf
Regular Visitor
4 years ago
Solved

Get Matrix row count ignore columns

I am trying to create a report with Average of scores, but I also want to show number of people with the scores in the visual.

 

Sample Data:

GenderItermScoreYear

ME14.52020
ME14.42020
ME14.52021
ME24.32021
ME24.52021
FE14.22021
FE14.52020
FE14.62021
FE14.52020
FE14.32021
FE14.42021
FE24.32021
FE14.22020
FE24.62021
FE24.62021
FE14.22021
FE24.52020
FE24.32021

 

My visual looks like this:

GenderE1E2
F4.364.46
M4.474.4

 

These are Average of scores, but I also want to add the row count. 

GenderCount of score
F13
M5

 

So ultimately, it should look like this:

GenderCountE1E2
F134.364.46
M54.474.4

 

Also need to preserve different filters/slicers. In this case, Year.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  chirag_usf ,

    Bring the Year field to the front

    Here are the steps you can follow:

    1. Create calculated table.

    Table_1 =
    var _summ=
    SUMMARIZE(
        'Table',
        'Table'[Year],'Table'[Genderl],
        "term","Count",
        "Sorce",COUNTX(FILTER(ALL('Table'),'Table'[Genderl]=EARLIER('Table'[Genderl])),[Genderl]))
    return
    UNION('Table',_summ)

    Table_2 =
    SUMMARIZE(
        'Table_1',
        'Table_1'[Year],'Table_1'[Genderl],'Table_1'[term],
        "Score",
        IF(
            'Table_1'[term] IN {"E1","E2"},        SUMX(FILTER(ALL('Table_1'),'Table_1'[term]=EARLIER('Table_1'[term])&&'Table_1'[Genderl]=EARLIER('Table_1'[Genderl])),[Score]) /      COUNTX(FILTER(ALL('Table_1'),'Table_1'[term]=EARLIER('Table_1'[term])&&'Table_1'[Genderl]=EARLIER('Table_1'[Genderl])),[term])
            ,      SUMX(FILTER(ALL('Table_1'),'Table_1'[term]=EARLIER('Table_1'[term])&&'Table_1'[Genderl]=EARLIER('Table_1'[Genderl])),[Score]) /2 )
    )

    2. Place it in the matrix Visual and set the Values field to Average.

    3. Result.

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

     

3 Replies

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

    Hi chirag_usf 
    Please refer to sample file withthe solution https://we.tl/t-ljhQEeEFHd

     

    Average Score = 
    IF (
        ISFILTERED ( Data[Iterm] ),
        AVERAGE ( Data[Score] ),
        FORMAT ( 
            CALCULATE (
                COUNTROWS ( Data ),
                ALL ( Data[Iterm] )
            ),
            "#"
        )
    )

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  chirag_usf ,

    Bring the Year field to the front

    Here are the steps you can follow:

    1. Create calculated table.

    Table_1 =
    var _summ=
    SUMMARIZE(
        'Table',
        'Table'[Year],'Table'[Genderl],
        "term","Count",
        "Sorce",COUNTX(FILTER(ALL('Table'),'Table'[Genderl]=EARLIER('Table'[Genderl])),[Genderl]))
    return
    UNION('Table',_summ)

    Table_2 =
    SUMMARIZE(
        'Table_1',
        'Table_1'[Year],'Table_1'[Genderl],'Table_1'[term],
        "Score",
        IF(
            'Table_1'[term] IN {"E1","E2"},        SUMX(FILTER(ALL('Table_1'),'Table_1'[term]=EARLIER('Table_1'[term])&&'Table_1'[Genderl]=EARLIER('Table_1'[Genderl])),[Score]) /      COUNTX(FILTER(ALL('Table_1'),'Table_1'[term]=EARLIER('Table_1'[term])&&'Table_1'[Genderl]=EARLIER('Table_1'[Genderl])),[term])
            ,      SUMX(FILTER(ALL('Table_1'),'Table_1'[term]=EARLIER('Table_1'[term])&&'Table_1'[Genderl]=EARLIER('Table_1'[Genderl])),[Score]) /2 )
    )

    2. Place it in the matrix Visual and set the Values field to Average.

    3. Result.

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly