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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
nok
Advocate II
Advocate II

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors