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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
dacougars
New Member

Trying to write a DAX caclulate formula with filters not working.

I am relatively new to power BI and I am trying to get a formula to work.  I am trying to calculate using a measure and filtering out certain codes to get the net revenue.  However when I enter the below formula I get the following error

 

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

 

=Calculate([Actual Gross Revenue],
FILTER(LEFT('Service Billed Revenue'[Account & Subaccount 2],4)="4120" ||
LEFT('Service Billed Revenue'[Account & Subaccount 2],4)="4263"))

 

How do I write the above formula?  If someone could help me with this would be appreciated. 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @dacougars

 

Without changing your tables in any way, I would write this particular formula like this:

=
CALCULATE (
    [Actual Gross Revenue],
    FILTER (
        VALUES ( 'Service Billed Revenue'[Account & Subaccount 2] ),
        LEFT ( 'Service Billed Revenue'[Account & Subaccount 2], 4 ) = "4120"
            || LEFT ( 'Service Billed Revenue'[Account & Subaccount 2], 4 ) = "4263"
    )
)

The main thing to note is that FILTER takes a table as its first argument, and a boolean expression as its second argument. The table can either be a physical table or a table produced by a DAX function. In this case, it is sufficient to filter the list of values in the column 'Service Billed Revenue'[Account & Subaccount 2] which is what VALUES ( 'Service Billed Revenue'[Account & Subaccount 2] ) gives us.

 

You may consider adding a column to the table 'Service Billed Revenue' that contains the first 4 characters of 'Service Billed Revenue'[Account & Subaccount 2], which will allow more efficient filtering. For example you could then write a measure like:

=
CALCULATE (
    [Actual Gross Revenue],
    'Service Billed Revenue'[Account & Subaccount 2 first 4 chars]
        IN { "4120", "4263" }
)

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

3 REPLIES 3
tex628
Community Champion
Community Champion

The filter function takes two expressions, like this:

 

FILTER( Table ; Filter expression )

 

In your example you include only the filter expression, you need to have something similar to this:

 

=Calculate([Actual Gross Revenue],
FILTER('Service BIlled Revenue',LEFT('Service Billed Revenue'[Account & Subaccount 2],4)="4120" ||
LEFT('Service Billed Revenue'[Account & Subaccount 2],4)="4263"))

 

You have to specify which table the filter is supposed to affect, in this case i assumed it to be 'Service BIlled Revenue'.

 

Hope this helps!

 

/ J


Connect on LinkedIn
OwenAuger
Super User
Super User

Hi @dacougars

 

Without changing your tables in any way, I would write this particular formula like this:

=
CALCULATE (
    [Actual Gross Revenue],
    FILTER (
        VALUES ( 'Service Billed Revenue'[Account & Subaccount 2] ),
        LEFT ( 'Service Billed Revenue'[Account & Subaccount 2], 4 ) = "4120"
            || LEFT ( 'Service Billed Revenue'[Account & Subaccount 2], 4 ) = "4263"
    )
)

The main thing to note is that FILTER takes a table as its first argument, and a boolean expression as its second argument. The table can either be a physical table or a table produced by a DAX function. In this case, it is sufficient to filter the list of values in the column 'Service Billed Revenue'[Account & Subaccount 2] which is what VALUES ( 'Service Billed Revenue'[Account & Subaccount 2] ) gives us.

 

You may consider adding a column to the table 'Service Billed Revenue' that contains the first 4 characters of 'Service Billed Revenue'[Account & Subaccount 2], which will allow more efficient filtering. For example you could then write a measure like:

=
CALCULATE (
    [Actual Gross Revenue],
    'Service Billed Revenue'[Account & Subaccount 2 first 4 chars]
        IN { "4120", "4263" }
)

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Thanks OwenAuger for the quick reply.  That is very helpful and makes sense to me. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors