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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Getting error in switch Fn

Hi,

 

I am getting error "The Expression Refers to Multiple Columns. Multiple Columns Cannot Be Converted to a Scalar Value."

in below function

 

 

Select Metric = IF(ISCROSSFILTERED('Metric '),
SWITCH(TRUE(),
VALUES('Metric ') = "Sales($)",ROUND([Select Sales],0),
VALUES('Metric ') = "Vol",ROUND([Select Trans],0),
VALUES('Metric ') = "customers",ROUND([Cust],0),
VALUES('Metric ') = "Sales Conversion(%)",ROUND([Sales Conversion],0),
VALUES('Metric ') = "AVG VOL($)",ROUND([Avg Vol],0),
VALUES('Metric ') = "Exit",ROUND([Exit],0), BLANK()),BLANK())
1 ACCEPTED SOLUTION
MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

I think you'd be better off using the SELECTEDVALUE function, as per below.

Select Metric =
VAR SelMetric = SELECTEDVALUE ( 'Metric ' )
VAR Result =
    SWITCH (
        TRUE (),
        SelMetric = "Sales($)", ROUND ( [Select Sales], 0 ),
        SelMetric = "Vol", ROUND ( [Select Trans], 0 ),
        SelMetric = "customers", ROUND ( [Cust], 0 ),
        SelMetric = "Sales Conversion(%)", ROUND ( [Sales Conversion], 0 ),
        SelMetric = "AVG VOL($)", ROUND ( [Avg Vol], 0 ),
        SelMetric = "Exit", ROUND ( [Exit], 0 ),
        BLANK ()
    )
RETURN
    Result

 

Best regards,
Martyn

 

View solution in original post

2 REPLIES 2
MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

I think you'd be better off using the SELECTEDVALUE function, as per below.

Select Metric =
VAR SelMetric = SELECTEDVALUE ( 'Metric ' )
VAR Result =
    SWITCH (
        TRUE (),
        SelMetric = "Sales($)", ROUND ( [Select Sales], 0 ),
        SelMetric = "Vol", ROUND ( [Select Trans], 0 ),
        SelMetric = "customers", ROUND ( [Cust], 0 ),
        SelMetric = "Sales Conversion(%)", ROUND ( [Sales Conversion], 0 ),
        SelMetric = "AVG VOL($)", ROUND ( [Avg Vol], 0 ),
        SelMetric = "Exit", ROUND ( [Exit], 0 ),
        BLANK ()
    )
RETURN
    Result

 

Best regards,
Martyn

 

Anonymous
Not applicable

Excellent Mate, Thanks Much

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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