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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
nok
Helper III
Helper III

Count rows in different months by ID

Hello,
I have a table that follows this structure:

IDDate
111   28/01/2025
11112/02/2025
22217/02/2024
22228/02/2025
33303/05/2025
33313/05/2025
33321/05/2025
44401/07/2025

 

I'm trying to create a measure that counts rows where the "Date" column has different months by "ID".
Because I want this measure to show, for each ID, if it has more than one row in different months. I tried to create this code, but it is returning me an error:

Count_Measure =
CALCULATE(
    COUNTROWS(MyTable),
    ALLEXCEPT(MyTable, MyTable[ID]),
    COUNTX(
        VALUES(MyTable[Date]),
        CALCULATE(DISTINCTCOUNT(MyTable[Date]))
    ) > 1
)
 

The expected result of this measure in a visual table would be something like this:

IDCount_Measure
111   2
2222
3330
4440

 

OBS: Note that ID 222 had the count "2" because although the two occurrences were in the same month (February), they are from different years.

How can I do this?

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

3 REPLIES 3
v-sathmakuri
Community Support
Community Support

Hi  @nok ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thanks!!

Ashish_Mathur
Super User
Super User

Hi,

Shouldn't the answer for 333 and 444 be 1?


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

lbendlin_0-1743800605422.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors