Forum Discussion
Identify ID changes
Hi serlurns,
Thank you for reaching out to the Microsoft Fabric Forum Community.
Try this Dax measures.
New IDs =
VAR CurrentMonth = SELECTEDVALUE('Table'[Month])
RETURN
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
'Table'[Month] = CurrentMonth &&
NOT 'Table'[ID] IN
CALCULATETABLE(
VALUES('Table'[ID]),
'Table'[Month] = CurrentMonth - 1
)
)
)
Deactivated IDs =
VAR CurrentMonth = SELECTEDVALUE('Table'[Month])
RETURN
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
'Table'[Month] = CurrentMonth - 1 &&
NOT 'Table'[ID] IN
CALCULATETABLE(
VALUES('Table'[ID]),
'Table'[Month] = CurrentMonth
)
)
)
Section Change =
VAR CurrentMonth = SELECTEDVALUE('Table'[Month])
VAR ChangedIDs =
FILTER(
ADDCOLUMNS(
VALUES('Table'[ID]),
"PrevSection", CALCULATE(MAX('Table'[Section]), 'Table'[Month] = CurrentMonth - 1),
"CurrSection", CALCULATE(MAX('Table'[Section]), 'Table'[Month] = CurrentMonth)
),
[PrevSection] <> [CurrSection]
&& NOT(ISBLANK([PrevSection]))
&& NOT(ISBLANK([CurrSection]))
)
VAR CurrentSection = SELECTEDVALUE('Table'[Section])
RETURN
SUMX(
ChangedIDs,
VAR PrevSec = [PrevSection]
VAR CurrSec = [CurrSection]
RETURN
SWITCH(
TRUE(),
CurrentSection = PrevSec && CurrentMonth > 1, -1,
CurrentSection = CurrSec, 1,
0
)
)
If you found this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to assist others in the community.
Thank you and best regards,
Prasanna Kumar