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

Don'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.

Reply
sdm2211
Frequent Visitor

Filter Problem

Dear all,

I am having following table with the mentioned data

BatsmanWicket_TypePlayer_Dismissed
KS BharatcaughtKS Bharat
KS BharatbowledKS Bharat
KS BharatstumpedKS Bharat
KS BharatcaughtKS Bharat
KS Bharatrun outKS Bharat
KS Bharatrun outV Kohli

 

above table shows Batsman KS Bharat is dismissed/out 5 times (caught-2, bowled-1, stumped-1, run out-1) hence ideally it should show me 5 times. however it showing me 6 times out (including that of V Kohli as well)

 

I used DAX formula as below

M Test =
Calculate(COUNTA(Deliveries[Player_Dismissed]),Filter(Deliveries,AND(Deliveries[Player_dismissed]<>"",Deliveries[Wicket_Type]<>"run out")))
however it is filtering 1 entry of "run out" for KS Bharat and returning count as 4 instead of 5. 
 
How can i achieve the correct result
 
8 REPLIES 8
Poojara_D12
Super User
Super User

Hi @sdm2211 

Can you please try this dax:

M Test =
CALCULATE(
    COUNTA(Deliveries[Player_Dismissed]),
    FILTER(
        Deliveries,
        Deliveries[Player_Dismissed] = Deliveries[Batsman] &&
        Deliveries[Player_Dismissed] <> "" &&
        Deliveries[Wicket_Type] <> ""
    )
)

 

  • Only rows where Player_Dismissed matches the Batsman are counted.
  • "Run out" is included if it applies to the same batsman.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
v-xianjtan-msft
Community Support
Community Support

Hi @sdm2211 

 

I'm sorry I can't fully understand your question, but as speedramps said, based on the table data you posted, it looks like your DAX returns result 4 correctly.
What is the 'Batsman_Runs' column mentioned in your latest reply?
Could you please provide sample data that completely covers your question and your expected results?


Please refer to the link below:

How to Get Your Question Answered Quickly - Microsoft Fabric Community

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

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

Hi @sdm2211 

 

I don't have access to this file.

vxianjtanmsft_0-1737599476460.png

 

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

Hi @sdm2211 

 

If I understand you correctly, you are trying to count the number of times each batsman dismissed. Based on your sample data, you can create the metric using the following DAX:

 

Dismissed_times = 
CALCULATE(
    COUNTROWS(Test),
    FILTER(
        Test,
        Test[Player_Dismissed] = Test[Batsman]
    )
)

 

vxianjtanmsft_0-1737612126405.png

 

In your measure, you filtered using AND(TEST[Player_Dismissed] = “”, TEST[Wicket_Type] = “run out”) and got result 3 as it should be.
You can verify this by manually filtering your data in Power BI:
1. Filtered by TEST[Player_Dismissed] = “”

vxianjtanmsft_1-1737612475850.png

vxianjtanmsft_2-1737612521940.png

vxianjtanmsft_3-1737612542620.png

2. Filtered by TEST[Wicket_Type] = “run out”

vxianjtanmsft_4-1737612584153.png

vxianjtanmsft_5-1737612614860.png

The final result of COUNTA(Test[Player_Dismissed]) is of course 3.

 

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

speedramps
Super User
Super User

You have used a FILTER .

The last 2 records dont have a blank playe_dismissed name

and the Type is not run_out.  So the answer is 4.

 

If you explain what you want rather than post your buggy DAX and expect us to fathom what you want, then we can try help. Thanks 😀

speedramps_0-1737393183065.png

 

Sorry for misleading information provided earlier. I am very new to PowerBI & DAX hence might not be able to construct my question properly. I am not able to attach sample PowerBI here  to explain my case

What I was saying is;

Column Batsman have 5 entries of KS Bharat

Column Batsman_Runs have sum of 10 for all those 5 entries

Column Player_Dismissed have 4 entries of KS Bharat and 1 entry of V Kohli

Column Wicket_Type have 4 entries for KS Bharat (2-caught, 1-bowled, 1-run out) and 1 entry for V Kohli (1-run out)

now as i earlier mentioned I used DAX formula

M Dismissed_Times=
Calculate(COUNTA(Test[Player_Dismissed]), FILTER(TEST, AND(TEST[Player_Dismissed]<>"",TEST[Wicket_Type]<>"run out")

 

which I know it is giving me wrong result.

 

I want Dismissed_Times should show 4 in the matrix, where it is showing 3 by using above wrong DAX formula.

sdm2211_0-1737397858777.png

 

 

 

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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