Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Fátima
Helper II
Helper II

DAX help - measure - number of items checked (mode)

Hi!

 

I'd swear I just posted this question, but now I can't find it anywhere.

 

I have a table like this:

COMP     ANSWER       CHECKED

1             1                    1

1             2                    0

1             3                    0

1             4                    1

1             5                    0

2             1                    0

2             2                    1

2             3                    0

2             4                    0

2             5                    1

3             1                    0

3             2                    1

3             3                    1

3             4                    1

3             5                    0

4             1                    1

4             2                    0

4             3                    0

4             4                    0

4             5                    0

5             1                    1

5             2                    1

5             3                    1

5             4                    1

5             5                    1

 

I need a measure that tells me the "mode" of how many "ANSWERS" have checked the column "COMP". For example, in this case:

COMP 1 has checked 2 answers

COMP 2 has checked 2 answers

COMP 3 has checked 3 answers

COMP 4 has checked 1 answer

COMP 5 has checked 5 answers

 

The most repeated case is that a COMP checks 2 answers, son I need the measure to return 2.

 

Is this possible?

 

Regards!

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1677004540229.png

 

 

Expected result measure: = 
VAR _newtable =
    GROUPBY (
        ADDCOLUMNS (
            DISTINCT ( Data[COMP] ),
            "@checkedcount", CALCULATE ( COUNTROWS ( Data ), Data[CHECKED] = 1 )
        ),
        [@checkedcount],
        "@countrows", SUMX ( CURRENTGROUP (), 1 )
    )
VAR _maxcountrows =
    MAXX ( _newtable, [@countrows] )
RETURN
    _maxcountrows

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi! Thanks for your answer!

 

I don't think it does what I need, because if I change the checks (in the COMP 1 I set 3 checked instead of 2), the expected result should be 3, and in your pbix I still get 2.

 

Regards!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.