The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi there,
I have a daily data of game played data in each location.
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.
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 |
Solved! Go to Solution.
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:
(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 :
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
Thank you Aniya! It works perfectly for me!
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:
(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 :
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
User | Count |
---|---|
83 | |
83 | |
37 | |
34 | |
32 |
User | Count |
---|---|
92 | |
79 | |
62 | |
53 | |
51 |