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
jboschee
Frequent Visitor

Mode Measure

Hi !

I'm trying to add a Mode measure into my prices matrix grid similiar to what I have below in excel.  My matrix is set up the same way in pbi.  It would be great if I could also find a way to count the number of prices that match the Mode.  Thanks in advance!

Product  Amazon  Walmart Bestbuy  Home Depot Lowes Target Mode
1200200150125300275200
250757575856075
3300300600450400500300
425506060604560
510010075756585100

 

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @jboschee 

According to your description, you want to get the [Mode] column in Power BI.Right?

For your need , i recommend you to realize it in Power Query Editor.

You can put this M code in the "Advanced Editor" in Power Query Editor:

vyueyunzhmsft_0-1670471580921.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY7BDcAwCAN34Z0HECDdBbH/Gg3QRsrnZGGDcQeCAYx4SFpk3Zw9XwoxHHjrMpdeeBKGlZlnq2lFqTUprdhJycv6n7Qb0o1pU3+Fd7F9xREv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product " = _t, #" Amazon " = _t, #" Walmart " = _t, #"Bestbuy " = _t, #" Home Depot " = _t, #"Lowes " = _t, #"Target " = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product ", Int64.Type}, {" Amazon ", Int64.Type}, {" Walmart ", Int64.Type}, {"Bestbuy ", Int64.Type}, {" Home Depot ", Int64.Type}, {"Lowes ", Int64.Type}, {"Target ", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", (x)=> Table.Sort(Table.AddColumn(Table.FromColumns({List.Skip(Record.ToList(x))}),"count",(y)=> Table.RowCount(Table.SelectRows(Table.FromColumns({List.Skip(Record.ToList(x))}),(z)=>z[Column1]=y[Column1])) ,type number    ),{"count",1})[Column1]{0}        )
in
    #"Added Custom"

Then we can meet your need:

vyueyunzhmsft_1-1670471592379.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

View solution in original post

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi , @jboschee 

According to your description, you want to get the [Mode] column in Power BI.Right?

For your need , i recommend you to realize it in Power Query Editor.

You can put this M code in the "Advanced Editor" in Power Query Editor:

vyueyunzhmsft_0-1670471580921.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY7BDcAwCAN34Z0HECDdBbH/Gg3QRsrnZGGDcQeCAYx4SFpk3Zw9XwoxHHjrMpdeeBKGlZlnq2lFqTUprdhJycv6n7Qb0o1pU3+Fd7F9xREv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product " = _t, #" Amazon " = _t, #" Walmart " = _t, #"Bestbuy " = _t, #" Home Depot " = _t, #"Lowes " = _t, #"Target " = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product ", Int64.Type}, {" Amazon ", Int64.Type}, {" Walmart ", Int64.Type}, {"Bestbuy ", Int64.Type}, {" Home Depot ", Int64.Type}, {"Lowes ", Int64.Type}, {"Target ", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", (x)=> Table.Sort(Table.AddColumn(Table.FromColumns({List.Skip(Record.ToList(x))}),"count",(y)=> Table.RowCount(Table.SelectRows(Table.FromColumns({List.Skip(Record.ToList(x))}),(z)=>z[Column1]=y[Column1])) ,type number    ),{"count",1})[Column1]{0}        )
in
    #"Added Custom"

Then we can meet your need:

vyueyunzhmsft_1-1670471592379.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Arul
Super User
Super User

@jboschee ,

Could you share the formula for mode calculation and mention which price column to compare Mode?

Thanks,





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


jboschee
Frequent Visitor

Hi @Arul ,

Here's the formula in excel =MODE(C2:H2).  Part of my question was how to get the mode in PBI and then do a count of the mode occurances as well.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors