cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
hosea_chumba
Helper I
Helper I

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value

Kindly assist on the below;
I get the error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value"  when i input the below formula to create a column. How do i solve it.
Inadequately secured loans =
VAR _inadequate_security = CALCULATE(FILTER('Table1','Table1'[Collateral Amount] < 1.5*'Table1'[Loan Amount]
 && 'Table1'[Product ID] <> {2222,8888}))
VAR _result_ = SWITCH(TRUE(),
_inadequate_security,"Inadeqaute Security",
"Adequate Security")
RETURN
_result_
 
Objective is to identify transactions that have collateral value that are not at least 150% of the loan amount excluding product 2222 and 8888
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

It's possible to have calculated tables inside a measure but if you want to return a table, then you need to use CALCULATETABLE rather than CALCULATE. However, since you are using _inadequate_security_ inside a SWITCH as if it is True/False, I suspect that you meant to have an argument in CALCULATE other than the filter table.

 

Did you intend to write something like this? (Note the line before FILTER.)

Inadequately secured loans =
VAR _inadequate_security =
    CALCULATE (
        ISEMPTY ( 'Table1' ),
        FILTER (
            'Table1',
            'Table1'[Collateral Amount] < 1.5 * 'Table1'[Loan Amount]
                && NOT ( 'Table1'[Product ID] IN { 2222, 8888 } )
        )
    )
VAR _result_ =
    SWITCH (
        TRUE (),
        _inadequate_security, "Inadeqaute Security",
        "Adequate Security"
    )
RETURN
    _result_

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

It's possible to have calculated tables inside a measure but if you want to return a table, then you need to use CALCULATETABLE rather than CALCULATE. However, since you are using _inadequate_security_ inside a SWITCH as if it is True/False, I suspect that you meant to have an argument in CALCULATE other than the filter table.

 

Did you intend to write something like this? (Note the line before FILTER.)

Inadequately secured loans =
VAR _inadequate_security =
    CALCULATE (
        ISEMPTY ( 'Table1' ),
        FILTER (
            'Table1',
            'Table1'[Collateral Amount] < 1.5 * 'Table1'[Loan Amount]
                && NOT ( 'Table1'[Product ID] IN { 2222, 8888 } )
        )
    )
VAR _result_ =
    SWITCH (
        TRUE (),
        _inadequate_security, "Inadeqaute Security",
        "Adequate Security"
    )
RETURN
    _result_

 

daXtreme
Solution Sage
Solution Sage

Hi there.

 

First and foremost, is this a measure? A calculated column?

 

The error you get stems from the fact that you cannot use CALCULATE to calculate tables in it, only scalar values, but FILTER does return a table, so it can't be used with CALCULATE as the first argument. The CALCULATE that you have wrapped FILTER in is totally unnecessary and, indeed, incorrect in this place. Also, please bear in mind you cannot return a table from a measure. Only scalar values are possible.

 

Incidentally, you have posted this question on a forum that deals with Power Query, not with DAX.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors