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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
erezbenmoshe
Advocate I
Advocate I

Count equal values across two rows

 

Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I am trying to write a measure that counts the number of [Id] where [Total] is the same for the two [Datatype]s, method1 and method2. 

 

The count for the data above should be 5.

 

Thanks!

Erez 

1 ACCEPTED SOLUTION

@erezbenmoshe

 

Here is a MEASURE

 

Measure =
COUNTX (
    FILTER (
        VALUES ( Table1[ID] ),
        CALCULATE ( SUM ( Table1[Total] ), Table1[Data Type] = "Method1" )
            = CALCULATE ( SUM ( Table1[Total] ), Table1[Data Type] = "Method2" )
    ),
    1
)

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

Will there only be 2 data types or can there be more as well?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Only 2 data types

Greg_Deckler
Community Champion
Community Champion

Well, one way to do this would be to use a calculated column like this:

 

SameTotal = COUNTX(FILTER(Table,Table[Id]=EARLIER(Table[Id]) && Table[DataType]<>EARLIER(Table[DataType]) && Table[Total]=EARLIER(Table[Total])),[Total])

Then you could create a measure that just SUM'd SameTotal or did a COUNT of SameTotal and divided the result of that by the number of methods.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@erezbenmoshe

 

Here is a MEASURE

 

Measure =
COUNTX (
    FILTER (
        VALUES ( Table1[ID] ),
        CALCULATE ( SUM ( Table1[Total] ), Table1[Data Type] = "Method1" )
            = CALCULATE ( SUM ( Table1[Total] ), Table1[Data Type] = "Method2" )
    ),
    1
)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.