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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi everyone,
I am trying to find a meassure for this example. I have one table of 2 years period (2021-2022), which includes client IDs and they can repeat. I need to calculate distinctcount of client IDs, which exists in 2021, but not exist in 2022.
In this example it should be distinctcount of klient_id = 2 (K100001 and K100003), because these are in 2021, but not in 2022. Also, I would like to use the meassure in bigger dataset then, so the meassure should comparing always last 12 months of date and previous 12 months from it (2021 and 2022; 2020 and 2021; 2019 and 2020; etc.).
Thanks for help.
Solved! Go to Solution.
You can try
Lost clients =
VAR MaxYear =
CALCULATE ( YEAR ( MAX ( 'Table'[Date] ) ), REMOVEFILTERS () )
VAR PrevYear = MaxYear - 1
VAR CurrentYearClients =
CALCULATETABLE (
VALUES ( 'Table'[Client ID] ),
TREATAS ( { MaxYear }, 'Date'[Year] ),
REMOVEFILTERS ( 'Date' )
)
VAR PrevYearClients =
CALCULATETABLE (
VALUES ( 'Table'[Client ID] ),
TREATAS ( { PrevYear }, 'Date'[Year] ),
REMOVEFILTERS ( 'Date' )
)
VAR NumLostClients =
COUNTROWS ( EXCEPT ( PrevYearClients, CurrentYearClients ) )
RETURN
NumLostClients
Hi @Anonymous
Do do you want to compare current year with the previous year or compare the past 12 months (from the max date available in the current filter context) to the 12 months before? Do you have adate table?
Hi,
I want to compare the past 12 months to the 12 months before.
You can try
Lost clients =
VAR MaxYear =
CALCULATE ( YEAR ( MAX ( 'Table'[Date] ) ), REMOVEFILTERS () )
VAR PrevYear = MaxYear - 1
VAR CurrentYearClients =
CALCULATETABLE (
VALUES ( 'Table'[Client ID] ),
TREATAS ( { MaxYear }, 'Date'[Year] ),
REMOVEFILTERS ( 'Date' )
)
VAR PrevYearClients =
CALCULATETABLE (
VALUES ( 'Table'[Client ID] ),
TREATAS ( { PrevYear }, 'Date'[Year] ),
REMOVEFILTERS ( 'Date' )
)
VAR NumLostClients =
COUNTROWS ( EXCEPT ( PrevYearClients, CurrentYearClients ) )
RETURN
NumLostClients
This works, thank you 🙂
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
User | Count |
---|---|
12 | |
11 | |
10 | |
9 | |
8 |