Forum Discussion

dvavrous's avatar
dvavrous
Frequent Visitor
2 years ago
Solved

Count values that equal to Maximum per category.

Hello,  hope I can get some help.  I need to count only the values that are equal to maximum value per that category_2. It has to be measure as I want to use multiple slicers. Each time I filte...
  • dvavrous's avatar
    dvavrous
    2 years ago

    Hello Jianpeng Li, thank you very much for your help.

    It worked on the data I sent but it did not work on my original data. 
    I must have made a mistake in my original measure that I shared.

    Anyway I was able to come up with a different approach that worked.

    For anyone interested see measure below.

    MEASURE =
    VAR _max_table =
    SUMMARIZE (
    ALLSELECTED ( 'Table 2' ),
    'Table 2'[category_1],
    'Table 2'[category_2],
    "max_evaluation", CALCULATE ( MAX ( 'Table 2'[evaluation] ) )
    )
    VAR _values =
    SELECTCOLUMNS (
    'Table 2',
    "category_1", 'Table 2'[category_1],
    "category_2", 'Table 2'[category_2],
    "evaluation", 'Table 2'[evaluation]
    )
    VAR _inter =
    INTERSECT ( _max_table, _values )
    RETURN
    COUNTROWS ( _inter )