Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
105 | |
79 | |
68 | |
63 |
User | Count |
---|---|
148 | |
107 | |
106 | |
82 | |
70 |