Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi Guys,
I am working on a cricket dataset and need to calculate the number of times a player got dismissed in a particular year. This is required for building the player stats where I calculate the player wise number of runs, average and strike-rate. However, the data is in the below form:
The above shows only filtered rows for balls faced by Rayudu. He is the player dismissed 13 out of 14 times and there is another batsman who got dismissed (Watson) on one of the occassion.
If i show the filtered view on the occasions when Rayudu got dismissed, we can see that on one of the occasions, the batsman facing is MS Dhoni. I am trying to understand how to create a measure which can calculate that Rayudu was dismissed 14 times in the current year.
While making the visualisation i would be making a table where i will select a player, his total runs, strike rate and average. This number of time a player got dismissed will be used for calculation of the average i.e. total runs/ no of time dismissed.
I tried the below expression:
But it returns the count of all the occassions when there was a dismissal when that player was batting i.e. the count of the rows in the first image. However, i would like to calculate the no of rows in the second image.
Thanks in advance.
@Anonymous
Try this
no_dismissed =
VAR __player =
SELECTEDVALUE ( deliveries[batsman] )
VAR __result =
CALCULATE (
COUNT ( deliveries[player_dismissed] ),
FILTER (
ALL ( deliveries[player_dismissed] ),
deliveries[player_dismissed] = __player
)
)
RETURN
__result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
This gives me a value of 13 for Rayadu.
I think it is not taking into account the dismissal where the batsman was Dhoni and Rayudu got dismissed.
Can you help incorporate that in the count somehow.
Hi @Anonymous ,
You need to have a seperate table for Players which is the dimension table.
Create the slicer from the Player's table and then follow the formula above. It should give you the value for AT Rayadu.
Incase you need some inspirations on the design.
https://community.powerbi.com/t5/Data-Stories-Gallery/IPL-Analysis-The-Criclytics/td-p/156504
https://www.youtube.com/watch?v=ujPuXZT7F6o&feature=youtu.be
Regards,
Harsh Nathani
@Anonymous
no_dismissed =
VAR __player =
SELECTEDVALUE ( deliveries[batsman] )
VAR __result =
CALCULATE (
COUNT ( deliveries[player_dismissed] ),
FILTER ( ALL ( 'deliveries' ), deliveries[player_dismissed] = __player )
)
RETURN
__result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
This takes away my year filter and gives me the count of how many times Rayadu got dismissed over the entire period of 12 years I am analysing (IPL seasons).
Can you also tell me how to avoid that?
Hi @Anonymous ,
Assume you have a Date Table too.
Incase not, you should try adding a Date Table.
Create a Date Table
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
https://www.sqlbi.com/articles/mark-as-date-table/
Regards,
Harsh Nathani
@Anonymous
Instead of ALL() function, use ALLEXCEPT(). Then specify the Year column.
https://docs.microsoft.com/en-us/dax/allexcept-function-dax
@Anonymous , did not get it completely , try
no_dismissed = CALCULATE(COUNT(deliveries[player_dismissed]),FILTER(ALL(deliveries[player_dismissed]),not(isblank(deliveries[player_dismissed]))))
This returns the number of bowls faced by that batsman somehow.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
21 | |
15 | |
15 | |
11 | |
7 |
User | Count |
---|---|
25 | |
24 | |
12 | |
12 | |
12 |