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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power Pivot Problems

I'M A STRUGGLING STUDENT AND IM ABOUT TO THROW MY LAPTOP. I'm currently using power pivot to generate a pivot table. The data has mock flight data with different routes and months of each flight. I am trying to create a column that calculates the most flied month (mode) for each route. I figured out how to calculate the mode using DAX commands but I am unable to filter it to each specific route because it is a value of a separate column. Is there any method that can group the different routes together?

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

@dufoq3 Thanks for your concern about this case!

Here is my sample data:

vjunyantmsft_0-1713767984536.png

You can achieve this in Power Query, put this M function into the Advanced Editor:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUo0BBKGSrE6RHON8HKNEVwjIGGCl2uKyjUDc52ArCSQUeZ4uRYILkivJSlcQwME3xjEN0TjG2HyYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [flight = _t, route = _t, month = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"flight", type text}, {"route", type text}, {"month", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"flight", "route", "month"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
    #"Grouped Rows Max" = Table.Group(#"Grouped Rows", {"flight", "route"}, {{"MaxCount", each List.Max([Count]), type number}}),
    #"Merged" = Table.Join(#"Grouped Rows", {"flight", "route", "Count"}, #"Grouped Rows Max", {"flight", "route", "MaxCount"})
in
    #"Merged"

 

And the final output is as below:

vjunyantmsft_1-1713768050795.png


If you must need DAX for calculated column, you can try this:
First add a Count column:

Count = 
CALCULATE(
    COUNT('Table'[month]),
    ALLEXCEPT('Table', 'Table'[route], 'Table'[month])
)

vjunyantmsft_0-1713770767571.png

Then use this DAX to create a calculated column:

MAX = 
VAR _max = CALCULATE(MAX('Table'[Count]),ALLEXCEPT('Table','Table'[route]))
VAR _route = 'Table'[route]
VAR result = CALCULATE(MIN('Table'[month]),FILTER(ALLEXCEPT('Table', 'Table'[route]), 'Table'[Count] = _max))
RETURN
result

And the final output is as below:

vjunyantmsft_1-1713770949099.png


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

dufoq3
Super User
Super User

Provide sample data in usable format please. If you don't know how - read note below. Don't forget to provide also expected result based on sample data.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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