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

See when key Fabric features will launch and what’s already live, all in one place and always up to date. Explore the new Fabric roadmap

Reply
Anonymous
Not applicable

VLOOKUP most repeated values

Hello All,

 

I've a table as below.

 

Category         Value

A                     1

A                     1

A                     1

A                     2

B                     3

B                     3

B                     3

B                     4

B                     4

C                     1

C                     1

C                     1

C                     1

C                     2

C                     2 

 

I have another table as below. I need to VLOOKUP and get the most repeated values in this table.

 

Category         Value

A        

B        

C          

My Desired outcome is as:

 

Category         Value

A                     1

B                     3

C                     1 

Can someone help me to get this output in Power Bi Desktop? Either VLOOKUP or any other possible method?

2 ACCEPTED SOLUTIONS

@Anonymous , you might want to tweak the measure this way,

Mode =
MAXX (
    TOPN (
        1,
        GROUPBY (
            FILTER ( 'Table', 'Table'[Value] <> 0 ),
            'Table'[Value],
            "cc", COUNTX ( CURRENTGROUP (), 1 )
        ),
        [cc]
    ),
    'Table'[Value]
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

Hi @Anonymous ,

 

First, CNENFRNL's formula can work well. You can also use the following measure:

Value1 = 
MAXX (
    TOPN (
        1,
       SUMMARIZE( FILTER('Table','Table'[Value]<>0),
            'Table'[Value],
            "_count", COUNT('Table'[Value])
        ),
        [_count]
    ),
    'Table'[Value]
)

 

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

 

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

Try these measures:

Value count = COUNT(Data[Value])
Most frequently appearing number = FIRSTNONBLANK ( TOPN ( 1, VALUES ( Data[Value] ), [Value count] ), 1 )

Drag the Category column and Most frequently appearing number measure to the Table visual.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
CNENFRNL
Community Champion
Community Champion

Simple enough

Screenshot 2021-04-04 211514.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi, Thank you!! It works but I am facing the below issue.

Category       Value

A                     0

A                     0

A                     2

A                     0

A                     0

A                     2

A                     0

A                     0

A                     2

 

Here I need to get 2 as expected output though 0 is the most repeated value. Can you please help me?

Hi,

Does this measure work?

Most frequently appearing number = FIRSTNONBLANK ( TOPN ( 1, FILTER(VALUES ( Data[Value] ),Data[value]<>0), [Value count] ), 1 )

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Anonymous , you might want to tweak the measure this way,

Mode =
MAXX (
    TOPN (
        1,
        GROUPBY (
            FILTER ( 'Table', 'Table'[Value] <> 0 ),
            'Table'[Value],
            "cc", COUNTX ( CURRENTGROUP (), 1 )
        ),
        [cc]
    ),
    'Table'[Value]
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

hi @CNENFRNL 

Thanks actually it works. I am not able to get the correct output if there is an additional column as below:


Date Category Value
1/1/2020 A 1
1/1/2020 A 1
1/1/2020 A 1
1/1/2020 A 2
1/1/2020 A 2
1/1/2020 B 3
1/1/2020 B 3
1/1/2020 B 3
1/1/2020 B 4
1/1/2020 B 5
1/1/2020 C 1
1/1/2020 C 2
1/1/2020 C 3
1/1/2020 C 3
1/1/2020 C 3
1/2/2020 A 7
1/2/2020 A 7
1/2/2020 A 7
1/2/2020 A 5
1/2/2020 A 6
1/2/2020 B 4
1/2/2020 B 4
1/2/2020 B 4
1/2/2020 B 4
1/2/2020 B 3
1/2/2020 C 9
1/2/2020 C 8
1/2/2020 C 8
1/2/2020 C 8
1/2/2020 C 5
1/3/2020 A 0
1/3/2020 A 0
1/3/2020 A 0
1/3/2020 A 1
1/3/2020 A 1
1/3/2020 B 2
1/3/2020 B 2
1/3/2020 B 2
1/3/2020 B 3
1/3/2020 B 3
1/3/2020 C 4
1/3/2020 C 4
1/3/2020 C 4
1/3/2020 C 4
1/3/2020 C 1


Desired Output:


Date Category Value
1/1/2020 A 1
1/1/2020 B 3
1/1/2020 C 3
1/2/2020 A 7
1/2/2020 B 4
1/2/2020 C 8
1/3/2020 A 1
1/3/2020 B 2
1/3/2020 C 4


Can you please help me here?

Hi @Anonymous ,

 

First, CNENFRNL's formula can work well. You can also use the following measure:

Value1 = 
MAXX (
    TOPN (
        1,
       SUMMARIZE( FILTER('Table','Table'[Value]<>0),
            'Table'[Value],
            "_count", COUNT('Table'[Value])
        ),
        [_count]
    ),
    'Table'[Value]
)

 

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

 

Anonymous
Not applicable

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.