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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Angie100701
New Member

Calculating mode for location level

Hi there,

 

I have a daily data of game played data in each location.

Angie100701_0-1681987207471.png

 

I have already add a new column to make daily data to weekly data.

I would like to make all locations into 4 levels based on their Amount Played and calculate the mode of level for each location.

However, I only got location level for each week, and I need help to calculate the mode.

 

Angie100701_1-1681987592060.png

 

Mode should be the following:

D

D

D

D

D

D

D

B

D

D

D

D

A

D

D

D

D

D

C

B

C

D

D

D

D

D

D

D

D

D

C

 

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

Hi ,  @Angie100701 

According to your description, you want to "Calculating mode for location level".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_4-1682319308739.png

 

(2)I create a measure as a level :

Level = IF( SUM('Table'[amount]) =1 , "D" , IF( SUM('Table'[amount]) =2 ,"C", IF( SUM('Table'[amount])=3,"B", "A")))

 

(3)Then we can  create a measure like this :

Measure = var _t =ADDCOLUMNS( CROSSJOIN( VALUES('Table'[Location]) , VALUES('Table'[week])) , "level" , [Level])
var _t2 =SUMMARIZE(_t , [level] , "count" , COUNT([week]))
var _max_count = MAXX(_t2,[count])
var _t3 = SELECTCOLUMNS( FILTER(_t2,[count]=_max_count) ,"level" , [level])
return
MINX(_t3,[level])

 

 

Then we can put this measure on the visual and we can get the result :

 vyueyunzhmsft_5-1682319320598.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

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

2 REPLIES 2
Angie100701
New Member

Thank you Aniya! It works perfectly for me!

v-yueyunzh-msft
Community Support
Community Support

Hi ,  @Angie100701 

According to your description, you want to "Calculating mode for location level".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_4-1682319308739.png

 

(2)I create a measure as a level :

Level = IF( SUM('Table'[amount]) =1 , "D" , IF( SUM('Table'[amount]) =2 ,"C", IF( SUM('Table'[amount])=3,"B", "A")))

 

(3)Then we can  create a measure like this :

Measure = var _t =ADDCOLUMNS( CROSSJOIN( VALUES('Table'[Location]) , VALUES('Table'[week])) , "level" , [Level])
var _t2 =SUMMARIZE(_t , [level] , "count" , COUNT([week]))
var _max_count = MAXX(_t2,[count])
var _t3 = SELECTCOLUMNS( FILTER(_t2,[count]=_max_count) ,"level" , [level])
return
MINX(_t3,[level])

 

 

Then we can put this measure on the visual and we can get the result :

 vyueyunzhmsft_5-1682319320598.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

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

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors