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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
MichaelHutchens
Helper IV
Helper IV

DAX table with filters and operators

Hi everyone, I'm trying to make a virtual table from an 'Employee' database that returns a list of employees. Each employee in the database might have multiple records, so in this virtual table, I only want the latest record with the highest record number, based on the 'Employee ID' field. I also only want records where the 'Current Employee Email Record' field = 'Y' OR the 'Employee Status' field = 'Withdrawn'.

So the logic should be = [Highest record number] AND ([Current Employee Email Record] OR [Employee Status])

I've given it a go with the table below, but I'm getting an error:

"Too few arguments were passed to the FILTER function. The minimum argument count for the function is 2."


Can anyone suggest where I'm going wrong? 🙂

Table 4 = 

FILTER(
ADDCOLUMNS(

'Employee',

"R", RANKX (

FILTER(

'Employee',

'Employee'[Email Address] =EARLIER ('Employee'[Email Address])), 'Employee'[Employee ID], , DESC) && 'Employee' [Current Employee Email Record]  =  "Y" || 'Employee' [Employee Status]  =  "Withdrawn"

),

 

3 REPLIES 3
v-junyant-msft
Community Support
Community Support

Hi @MichaelHutchens ,

Please try this DAX:

Table 4 =
VAR EmployeeLatestRecord = 
    ADDCOLUMNS(
        GROUPBY(
            'Employee',
            'Employee'[Employee ID],
            "MaxRecordNumber", MAXX(CURRENTGROUP(), 'Employee'[Record Number])
        ),
        "EmployeeDetails", CALCULATETABLE(
            'Employee',
            FILTER(
                'Employee',
                'Employee'[Record Number] = [MaxRecordNumber]
            )
        )
    )
RETURN
FILTER(
    EXPANDTABLECOLUMN(EmployeeLatestRecord, "EmployeeDetails"),
    'Employee'[Current Employee Email Record] = "Y" || 'Employee'[Employee Status] = "Withdrawn"
)

I'm not sure this is useful, if it doesn't solve your problem, please provide some sample data, thanks!

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

gadielsolis
Super User
Super User

Please try the following:


FILTER(
ADDCOLUMNS(

'Employee',

"R", RANKX (

FILTER(

'Employee',

'Employee'[Email Address] =EARLIER ('Employee'[Email Address])), 'Employee'[Employee ID], , DESC) ,
'Employee' [Current Employee Email Record] = "Y" || 'Employee' [Employee Status] = "Withdrawn"

)

EDIT: I'd replied to your first post, not the correction

Thanks @gadielsolis , but I'm getting an error with that code:

MichaelHutchens_0-1705519789912.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.