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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
AgniAnkit
Microsoft Employee
Microsoft Employee

DistinctIDs for each month ids should not be repetitive.

Hi  everyone,

 

I need help in building a logic to get the distinct ids from a table for each month and ids should not be repeatitive from past month. attahced screenshot with example data. 

 

help would be much appriciated.

 

AgniAnkit_0-1678207414727.png

 

3 ACCEPTED SOLUTIONS
tamerj1
Super User
Super User

Hi @AgniAnkit 

Please try

DistinctCount =
COUNTROWS (
EXCEPT (
VALUES ( Data[ID] ),
CALCULATETABLE (
VALUES ( Data[ID] ),
'Date'[Start of Month] < MAX ( 'Date'[Start of Month] ),
ALL ( 'Date' )
)
)
)

View solution in original post

Thankyou so much. It is giving the correct counts, however total is not coming correct , it is showing last month count.

View solution in original post

@AgniAnkit 

Please try

DistinctCount =
SUMX (
VALUES ( 'Date'[Month] ),
CALCULATE (
COUNTROWS (
EXCEPT (
VALUES ( Data[ID] ),
CALCULATETABLE (
VALUES ( Data[ID] ),
'Date'[Start of Month] < MAX ( 'Date'[Start of Month] ),
ALL ( 'Date' )
)
)
)
)
)

View solution in original post

6 REPLIES 6
AgniAnkit
Microsoft Employee
Microsoft Employee

Thankyou so much 🙂

tamerj1
Super User
Super User

Hi @AgniAnkit 

Please try

DistinctCount =
COUNTROWS (
EXCEPT (
VALUES ( Data[ID] ),
CALCULATETABLE (
VALUES ( Data[ID] ),
'Date'[Start of Month] < MAX ( 'Date'[Start of Month] ),
ALL ( 'Date' )
)
)
)

Thankyou so much. It is giving the correct counts, however total is not coming correct , it is showing last month count.

@AgniAnkit 

What should be the total? Do you want to sum the values of each month over the months? Should be doable but what meaning does that total hold?

Sum of the values of each month.

Thankyou

@AgniAnkit 

Please try

DistinctCount =
SUMX (
VALUES ( 'Date'[Month] ),
CALCULATE (
COUNTROWS (
EXCEPT (
VALUES ( Data[ID] ),
CALCULATETABLE (
VALUES ( Data[ID] ),
'Date'[Start of Month] < MAX ( 'Date'[Start of Month] ),
ALL ( 'Date' )
)
)
)
)
)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.