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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
sdm2211
Frequent Visitor

Count number of centuries scored by Batsman

dear All,

 

I need to know how can I calculate the number of times batsman scored a century (i.e. runs more than 99)

 

please find attached dataset here.

https://docs.google.com/spreadsheets/d/105JwwAVlZQXZmjBx4XssVPJVd0t7yfRR/edit?usp=drive_link&ouid=11... 

1 ACCEPTED SOLUTION

Hi @sdm2211 

 

Would a measure like this help?

 

GT 5s = 
    COUNTROWS(
        FILTER(
            ADDCOLUMNS(
                SUMMARIZE(
                    'Table 1',
                    'Table 1'[Match_ID],
                    'Table 1'[Innings],
                    'Table 1'[Batsman]
                ),
                "_Runs", CALCULATE( SUM( 'Table 1'[Batsman_Runs] ) )
            ),
            [_Runs] >= 5
        )
    )

 

 

Let me know if you have any questions.



Proud to be a Super User!

daxformatter.com makes life EASIER!

View solution in original post

5 REPLIES 5
sdm2211
Frequent Visitor

@v-jiewu-msft @Greg_Deckler ,

For simplification, assume runs scored more than or equal to 5. I have made the Excel Pivot to explain my case better.

 

Sum of Batsman_Runs Innings    
BatsmanMatch_ID1234Grand Total
CT Bancroft114 9 23
 322  4
 134   4
DA Warner112 5 17
 31313  26
 134   4
JM Anderson13   1010
SCJ Broad13   44
UT Khawaja137   7
Grand Total 5615141499

 

Here we can see, 

CT Bancroft scored more than or equal to 5 runs, 2 times (Match ID 1, Innings 1 & 3)

DA Warner scored more than or equal to 5 runs, 4 times (Match ID 1, Innings 1 & 3, Match ID 3, Innings 1 & 2)

JM Anderson scored more than or equal to 5 runs, 1 time (Match ID 13, Innings 4)

UT Khawaja scored more than or equal to 5 runs, 1 time (Match ID 13, Innings 1)

 

Now PowerBI Matrix should show information as below.

DA Warner4
CT Bancroft2
JM Anderson1
UT Khawaja1

 

adding the link where you can access this information

https://drive.google.com/drive/folders/1DOSWha08loopaKXBPgx8KmFiidy4CQTm?usp=sharing 

 

Hope I have elaborated more.

Hi @sdm2211 

 

Would a measure like this help?

 

GT 5s = 
    COUNTROWS(
        FILTER(
            ADDCOLUMNS(
                SUMMARIZE(
                    'Table 1',
                    'Table 1'[Match_ID],
                    'Table 1'[Innings],
                    'Table 1'[Batsman]
                ),
                "_Runs", CALCULATE( SUM( 'Table 1'[Batsman_Runs] ) )
            ),
            [_Runs] >= 5
        )
    )

 

 

Let me know if you have any questions.



Proud to be a Super User!

daxformatter.com makes life EASIER!

Hi @gmsamborn this code worked like magic 🤗

v-jiewu-msft
Community Support
Community Support

Hi ,

The file link is not opening, either upload it another way or provide the sample data in text format in your reply. Provide the expected data results as well.

 

Best Regards,

Wisdom Wu

Greg_Deckler
Super User
Super User

@sdm2211 For those of us unfamiliar with Cricket, is that per game or across multiple games? Is this for a single person (batsman) or for multiple people? If you could provide the specific details/logic around what exactly counts as a "century" that would be really helpful.

 

In general, however, you are going to create a table variable using SUMMARIZE. There you would group your data depending on the requirements and you would include the calculation of a column that sums up the runs. Then you can FILTER that table to where the runs are > 99 and do a COUNTROWS around that filtered table.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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