Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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.
Solved! Go to Solution.
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.
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' )
)
)
)
)
)
Thankyou so much 🙂
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.
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
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' )
)
)
)
)
)
User | Count |
---|---|
15 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
18 | |
13 | |
7 | |
5 |