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

count of mode

Hello,

 

I'm trying to count the number of times my Mode measure is equal to the prices in the row.  I want to duplicate the Mode Count column below.

 

Any help would be appreciated!

 

Product  Amazon  Walmart Bestbuy  Home Depot Lowes Target Mode Count
12002001501253002752
25075757585603
33003006004504005002
42550606060453
5100100757565852
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jboschee 

 

You need to unpivot the column first, you can put the following code in Advanced Editor in power query

 

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}}),

    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Product"}, "Attribute", "Value")

in

    #"Unpivoted Other Columns"

Then apply it to table, and create a measure in the table

 

Mode = COUNTAX(FILTER(ALL('Table'),'Table'[Product]=SELECTEDVALUE('Table'[Product])&&'Table'[Value]=SELECTEDVALUE('Table'[Value])),[Value])

Output:

vxinruzhumsft_0-1670468193254.png

 

Best Regards,

Yolo Zhu

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

1 REPLY 1
Anonymous
Not applicable

Hi @jboschee 

 

You need to unpivot the column first, you can put the following code in Advanced Editor in power query

 

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}}),

    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Product"}, "Attribute", "Value")

in

    #"Unpivoted Other Columns"

Then apply it to table, and create a measure in the table

 

Mode = COUNTAX(FILTER(ALL('Table'),'Table'[Product]=SELECTEDVALUE('Table'[Product])&&'Table'[Value]=SELECTEDVALUE('Table'[Value])),[Value])

Output:

vxinruzhumsft_0-1670468193254.png

 

Best Regards,

Yolo Zhu

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

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