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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dogt1225
Helper III
Helper III

Function CONTAINSROW must have a value for each column in the table expression -- Error Help

I am creating a custom period slicer for my report. 

dogt1225_2-1680560196818.png

 

"Date" table is my date table and is connected with relationships to my multiple dates in multiple fact tables


"New Date" is a standalone table that has no relationships with any of my fact tables. It is 

New Date = DISTINCT('Date'[Date])



I have created a new measure "Period Filter" to filter the x-axis on a line graph visual so users can select the period. 

 

 

 

Period Filter = 

VAR _selectedperiod = SELECTEDVALUE('Last 5 Custom Period'[Period-Order])

VAR _last5qtr = 
    MAX('Date'[Date]) IN
    FILTER('New Date', 'New Date'[Fiscal Year Quarter Offset] >= -4 && 'New Date'[Fiscal Year Quarter Offset] <= 0 && 'New Date'[Fiscal Year Week Offset] <> BLANK())

VAR _last5months = 
    MAX('Date'[Date]) IN
    FILTER('New Date', 'New Date'[Fiscal Year Month Offset] >= -4 && 'New Date'[Fiscal Year Month Offset] <= 0 && 'New Date'[Fiscal Year Week Offset] <> BLANK())

VAR _last5wks = 
    MAX('Date'[Date]) IN
    FILTER('New Date', 'New Date'[Fiscal Year Week Offset] >= -4 && 'New Date'[Fiscal Year Week Offset] <= 0 && 'New Date'[Fiscal Year Week Offset] <> BLANK())

RETURN

    INT(SWITCH(
            _selectedperiod, 1, _last5qtr, 
                             2, _last5months, 
                             3, _last5wks
    ))

 

 

The "Last 5 Custom Period" table is as follows:

dogt1225_0-1680559746783.png

 

I am getting the following error with the [Period Filter] measure:

dogt1225_1-1680559942575.png

"The number of arguements is invalid. Function CONTAINSROW must have a value for each column in the table expression"


I am not using the CONTAINSROW function. Any ideas on how to resolve this error and whats causing it?

7 REPLIES 7
prabhatnath
Advocate III
Advocate III

Hi All,

 

Have you found how to fix that? As I am getting the same error and looks like below MonthToDate does not give any issues.

VAR MonthToDate =
    MAX ( Incidents[Created Date] ) IN DATESMTD ( ALL('Date Dimention'[Date] ) )

 

While below statements that has IN FILTER or IN ALL gives the issue:

 

VAR _Last7Days =
    MAX ( Incidents[Created Date] ) IN
        FILTER (
            'Date Dimention',
            'Date Dimention'[Date] <= TODAY ()
                && 'Date Dimention'[Date]
                    >= TODAY () - 7
        )
 
or
 
VAR _CustomSelection =
    MAX ( Incidents[Created Date] ) IN ALL ( 'Date Dimention' )
 
Can anyone suggest the issue with these 2 statements please?
Thanks,
Prabhat
 

 

Looks like the the MAX function excepts a single value but the FILTER function is returning a TABLE as the Date Dimention table has multiple columns. Below changes will solve the error.

 

Last7Days = CALCULATE(
    COUNTROWS(Incidents),
        FILTER(
            ALL('Date Dimention'),
            'Date Dimention'[Date] <= TODAY()
            && 'Date Dimention'[Date] >= TODAY() - 7
        )
)

 

jdmontes
Regular Visitor

I would try this:

 

VAR _tableLast5qtr =

FILTER( 'New Date', 'New Date'[Fiscal Year Quarter Offset] >= -4 &&

'New Date'[Fiscal Year Quarter Offset] <= 0 &&

'New Date'[Fiscal Year Week Offset] <> BLANK()

)

 

VAR _last5qtr = CONTAINS(

_tableLast5qtr,

[select the proper column to comper with],

MAX('Date'[Date])

)

Mrtnkbg
Advocate I
Advocate I

Hi @dogt1225 

 

I'm a bit late to the party, but for what it's worth:

 

What I note without diving to deep into the case, is that the IN syntax requires that the values listed are placed within curly brackets, and should be such as:

'Table'[ColumnA] IN {val1, val2} or 'Table'[ColumnA] IN {"A", "B"} etc. depending on the data type.

(It's explained in the link that @vicky_ gave you, i.e. The IN operator in DAX - SQLBI, scroll down to the line "With the new IN syntax, you can write: ")

 

This way you should hopefully (at least) get you past the CONTAINSROW error message.

EHolder5G
Regular Visitor

Have you found a solution to this? I'm having the same problem when I try to build a similar filter.

vicky_
Super User
Super User

The IN keyword is calling the containsrow function: https://www.sqlbi.com/articles/the-in-operator-in-dax/

Thanks, any ideas on how to make it a valid measure?

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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