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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
bradc
Frequent Visitor

Filter on multiple table columns

Hi All,

 

I'm trying to create a [FILTER] column in a table that will return TRUE for the minimum [ITEM NUMBER], in an [ITEM GROUP], after the last recorded [FINISH DATE] that is not blank.  The data in the table looks much like this below, and the FILTER column shows the desired result.

bradc_0-1732155030939.png

I see there are similar problems that have been solved, but I'm really struggling to apply those solutions to my specific need. 

 

All help is much appreciated.

B

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

Hi @bradc ,

Create a new calculated column using this DAX code:

FILTER = 
VAR LastFinishDate =
    CALCULATE(
        MAX('Table'[FINISH DATE]),
        ALLEXCEPT('Table', 'Table'[ITEM GROUP])
    )
VAR MinItemNumberAfterDate =
    CALCULATE(
        MIN('Table'[ITEM NUMBER]),
        ALLEXCEPT('Table', 'Table'[ITEM GROUP]),
        'Table'[FINISH DATE] > LastFinishDate || ISBLANK('Table'[FINISH DATE])
    )
RETURN
'Table'[ITEM NUMBER] = MinItemNumberAfterDate

 

Consider this notes:
In my case, ITEM NUMBER 2 is marked as "TRUE" in the FILTER column because it is considered the last record based on the most recent date in the FINISH DATE column within each ITEM GROUP, as shown below:

Bibiano_Geraldo_0-1732196385255.png

 

 

View solution in original post

4 REPLIES 4
Bibiano_Geraldo
Super User
Super User

Hi @bradc ,

Create a new calculated column using this DAX code:

FILTER = 
VAR LastFinishDate =
    CALCULATE(
        MAX('Table'[FINISH DATE]),
        ALLEXCEPT('Table', 'Table'[ITEM GROUP])
    )
VAR MinItemNumberAfterDate =
    CALCULATE(
        MIN('Table'[ITEM NUMBER]),
        ALLEXCEPT('Table', 'Table'[ITEM GROUP]),
        'Table'[FINISH DATE] > LastFinishDate || ISBLANK('Table'[FINISH DATE])
    )
RETURN
'Table'[ITEM NUMBER] = MinItemNumberAfterDate

 

Consider this notes:
In my case, ITEM NUMBER 2 is marked as "TRUE" in the FILTER column because it is considered the last record based on the most recent date in the FINISH DATE column within each ITEM GROUP, as shown below:

Bibiano_Geraldo_0-1732196385255.png

 

 

Thank you so much for your answer.

Both responses have help me understand filters and the use of variables in DAX a little better.

 

I have failed to describe adequately just what I was after, but using the solutions provided I think I have come up with the solution I needed.   This solution didn't quite meet my need as it returned the first Item Number without a finish date.  What I actually needed was the first item number AFTER the last recorded finish date.

bradc_1-1732236240745.png

 

The variable calculating the Max recorded last finish date for the item was extremely useful however.

This is the solution I ended up applying. 

FILTER_3 =
//VAR LastFinishDate = CALCULATE(MAX('Table'[FINISH DATE]), ALLEXCEPT('Table', 'Table'[ITEM GROUP]))
VAR MaxItemNumberWithDate = CALCULATE(MAX('Table'[ITEM NUMBER]),ALLEXCEPT('Table', 'Table'[ITEM GROUP]),'Table'[FINISH DATE] <> Blank())
RETURN 'Table'[ITEM NUMBER] = MaxItemNumberWithDate +1

Hope others can utilise and learn from the infomration provided here.

Again, thank you so much for your answer.  It is much appreciated.

Hi @bradc, happy you find the last way.

This is great solution. 

 

 

 

Jihwan_Kim
Super User
Super User

Hi, I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file. It is for creating a new column.

 

Jihwan_Kim_0-1732162184527.png

 

 

filter CC =
VAR _T =
    FILTER (
        data,
        data[item group] = EARLIER ( data[item group] )
            && data[item number] < EARLIER ( data[item number] )
            && data[finish date] <> BLANK ()
    )
VAR _RecentItemNumberNonBlankFinishDate =
    MAXX ( _T, data[item number] )
VAR _NextItemNumber = _RecentItemNumberNonBlankFinishDate + 1
RETURN
    IF (
        _RecentItemNumberNonBlankFinishDate <> BLANK (),
        data[item number] = _NextItemNumber
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors