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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
travellers_173
New Member

Group based on max occurance of text field instead of max considering alphabetical letter

Hi,

 

New to Power BI and stuck on this. I am trying to get the max occured value while grouping the data for each month. In the below data for Jan Closed is more so I want the result group for ABC(Name), 1-Jan-23 (Month), Closed. But when I did a group by in Power query it is saying Open for Jan since O is max alphabetically. How to achieve this in Power Query (M) and no in Dax?

 

NameMonthStatus
ABC01-Jan-23Closed
ABC01-Jan-23Closed
ABC01-Jan-23Closed
ABC01-Jan-23Closed
ABC01-Jan-23Open
ABC01-Feb-23Open
ABC01-Feb-23Open
ABC01-Feb-23Closed
ABC01-Feb-23Closed
ABC01-Feb-23Closed
ABC01-Feb-23Open
ABC01-Mar-23 
ABC01-Mar-23 
ABC01-Mar-23 
2 REPLIES 2
Anonymous
Not applicable

Hi  @travellers_173 ,

vyangliumsft_0-1677563225642.png

 

Here are the steps you can follow:

1. Create calculated column.

Flag =
COUNTX(
    FILTER(ALL('Table'),
'Table'[Name]=EARLIER('Table'[Name])&&MONTH('Table'[Month])=MONTH(EARLIER('Table'[Month]))&&'Table'[Status]=EARLIER('Table'[Status])),
    [Name])

2. Create calculated table.

Table 2 =
DISTINCT(
FILTER(
    'Table',   
    'Table'[Flag]=
    MAXX(        FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&MONTH('Table'[Month])=MONTH(EARLIER('Table'[Month]))),[Flag])))

3. Result:

vyangliumsft_1-1677563225644.png

 

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

lbendlin
Super User
Super User

lbendlin_0-1676850301340.png

 

Please indicate what should happen in case of a tie (February)  and in case of missing status (March)

 

Note that Power Query is case sensitive and does not trim values.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Users online (2,306)