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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
dogt1225
Helper II
Helper II

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.