Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
fabiocovre
Advocate I
Advocate I

Measure to indicate Active/Excluded people

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.

1.PNGAbove 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).

 

2.PNG

Thank you!

Fabio

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

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.

View solution in original post

1 REPLY 1
sturlaws
Resident Rockstar
Resident Rockstar

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.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.