There's more...

We can use the same basic technique to calculate the mode of multiple columns. To see how this works, perform the following steps:

  1. Use another Enter Data query to create a table called R08_Table2 with the following data:

Index

M1

M2

M3

M4

0

AAA3

AAA3

AAA3

AAA3

1

BBB3

CCC3

CCC3

2

DDD2

  1. Create the following measure:
MMode = 
VAR __Table =
UNION(
UNION(
UNION(
SUMMARIZE('R08_Table2','R08_Table2'[Index],"__Methods",MAX('R08_Table2'[M1])),
SUMMARIZE('R08_Table2','R08_Table2'[Index],"__Methods",MAX('R08_Table2'[M2]))
),
SUMMARIZE('R08_Table2','R08_Table2'[Index],"__Methods",MAX('R08_Table2'[M3]))
),
SUMMARIZE('R08_Table2','R08_Table2'[Index],"__Methods",MAX('R08_Table2'[M4]))
)
VAR __Table1 =
FILTER(
GROUPBY(__Table,[Index],[__Methods],"__Count", COUNTX(CURRENTGROUP(), [__Methods])),
[__Methods]<>""
)
VAR __Table2 = FILTER(__Table1,[__Count] = MAXX(__Table1,[__Count]))
VAR __Mode =
IF(
COUNTROWS( __Table2 ) = 1,
MAXX( __Table2 , [__Methods] ),
CONCATENATEX( __Table2 , [__Methods] , ",")
)
RETURN __Mode
  1. Create a Card visualization and place the MMode measure in the Fields area for the Card visualization.

This technique is extremely similar to our Mode measure. The primary difference is the use of the UNION statements. These UNION statements require some sort of unique row identifier, in this case, our Index column. We use SUMMARIZE to group our table rows by the Index column with the value for our columns, M1, M2, M3, and M4. Each of these SUMMARIZE statements returns a two-column table that lists each index value coupled with each value from the columns M1, M2, M3, and M4. Thus, the first SUMMARIZE statement would return a table along the lines of the following:

Index

__Methods

0

AAA3

1

BBB3

2

 

We use UNION to combine all of these tables together so that we have essentially in-pivoted our columns M1, M2, M3, and M4 into a single column called __Methods. Thus, at this point, we are essentially performing the same calculation as our original Mode measure!

You should note that this same technique of un-pivoting columns using DAX can be used to calculate any multicolumn aggregation, including SUM, AVERAGE, MIN, MAX, COUNT, and even PRODUCT.