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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mkins
Helper I
Helper I

Count if final value in column equals a specified text, with filter applied

Hi there,

 

I have the results from a table tennis match where in one column I have the Game Score (Game 1, Game 2, Game 3, etc), and Point Won By column (the name of the player who wins the point).

 

I would like to be able to calculate how many games each player wins in the match. This would require me to use some DAX and COUNTROWS where the Game Score = "Game 1" (this maybe recorded 20 times if there were 20 points in the game) and the final instance of this value I refer to the Point Won By column to see who that player was. This is because who ever wins the final point in Game 1 will have therefore won this game. 

 

I hope this makes sense, and any help would be much appreciated.

 

Thanks you,

 

M

 

 

 

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

Hi, @mkins 

 

Thank you very much for @danextian reply. Based on your description, I have created a new column to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1711525887089.png

 

New column:

 

Winner =

VAR CurrentGame = 'Game'[Game]

VAR CurrentIndex = 'Game'[Index]

VAR MaxIndexInSameGame =

    CALCULATE (

        MAX ( 'Game'[Index] ),

        FILTER ( 'Game', 'Game'[Game] = CurrentGame )

    )

RETURN

    IF ( CurrentIndex = MaxIndexInSameGame, 1, BLANK () )

 


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

 

View solution in original post

3 REPLIES 3
v-yaningy-msft
Community Support
Community Support

Hi, @mkins 

 

Thank you very much for @danextian reply. Based on your description, I have created a new column to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1711525887089.png

 

New column:

 

Winner =

VAR CurrentGame = 'Game'[Game]

VAR CurrentIndex = 'Game'[Index]

VAR MaxIndexInSameGame =

    CALCULATE (

        MAX ( 'Game'[Index] ),

        FILTER ( 'Game', 'Game'[Game] = CurrentGame )

    )

RETURN

    IF ( CurrentIndex = MaxIndexInSameGame, 1, BLANK () )

 


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

 

danextian
Super User
Super User

Hi @mkins 
As always, please provide a workable sample data (not an image) and your expected result from that.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian thank you for reaching out.

Please fsee example table below. As player A wins the last instance of Game 1, and Game 3, their score equals 2. Player B wins the last instance/ point in Game 2, so their score is 1. Would like to know what DAX is needed to calculate this.

Hope this makes sense.

Thanks

GamePoint Won by
1

Player B

1Player A
1Player A
2Player A
2Player B
2Player B
3Player A
3Player A
3Player A

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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