The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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 | |
12 | |
7 | |
6 | |
6 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |