Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I need to create a measure to indicate if a person is active or excluded of the data. To that, I have a census fact table where exists the users name being repeated every month. What I want to do is case a user don't be present in the last month of this fact table, I indicate him as Excluded, otherwise, she remains Active.
Above is an example what I did. The highlighted user is "Excluded" because the last time she appeared in the census fact table was on nov/2021.
The problem that I'm facing is when I filter a specific month, for example sep/21 and indicates that she's Active now. What I need is that, independent of what filter I'm using, the DAX formula always return her a Excluded status based on the last month of the model (apr/22 in this case).
Thank you!
Fabio
Solved! Go to Solution.
Hi, @fabiocovre,
I think a measure like this would do the trick:
Is active/inactive =
VAR _lastMonth =
CALCULATE ( MAX ( 'Table'[Month] ), REMOVEFILTERS () )
VAR _user =
SELECTEDVALUE ( 'Users'[User] )
VAR _isActiveLastMonth =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( ALL ( 'Table' ), 'Table'[User] = _user && 'Table'[Month] = _lastMonth )
)
VAR _result =
IF (
ISBLANK ( _user ),
BLANK (),
IF (
ISBLANK ( _isActiveLastMonth )
&& NOT ( ISBLANK ( SELECTEDVALUE ( Users[User] ) ) ),
"Inactive",
"Active"
)
)
RETURN
_result
as you have not provided a sample report, I have used some generic names for table and columns, you will of course need to adapt this to your model.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Hi, @fabiocovre,
I think a measure like this would do the trick:
Is active/inactive =
VAR _lastMonth =
CALCULATE ( MAX ( 'Table'[Month] ), REMOVEFILTERS () )
VAR _user =
SELECTEDVALUE ( 'Users'[User] )
VAR _isActiveLastMonth =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER ( ALL ( 'Table' ), 'Table'[User] = _user && 'Table'[Month] = _lastMonth )
)
VAR _result =
IF (
ISBLANK ( _user ),
BLANK (),
IF (
ISBLANK ( _isActiveLastMonth )
&& NOT ( ISBLANK ( SELECTEDVALUE ( Users[User] ) ) ),
"Inactive",
"Active"
)
)
RETURN
_result
as you have not provided a sample report, I have used some generic names for table and columns, you will of course need to adapt this to your model.
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
70 | |
68 | |
43 | |
34 | |
26 |
User | Count |
---|---|
88 | |
52 | |
45 | |
39 | |
38 |