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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pierre415
Helper I
Helper I

SWITCH() - A table of multiple values was supplied where a single value was expected

Measure Selection = 
 SWITCH( TRUE(),
	VALUES('ADMIN Year Slicer'[Custom]) = "2015",[2015 Turnover Rate],
	VALUES('ADMIN Year Slicer'[Custom]) = "2016",[2016 Turnover Rate],
	VALUES('ADMIN Year Slicer'[Custom]) = "2017",[YTD Turnover Rate],BLANK()
)


I'm using the SWITCH method outlined in this article -http://community.powerbi.com/t5/Community-Blog/Dynamically-change-the-information-within-a-visual-vi...

 

But I'm getting the error message above which I can't figure out. Here's the Measure selection table I'm using.Capture.PNG

 

Any ideas why this is happening? Thanks,

 

Pierre

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @pierre415,

 

The VALUES function will return all the values of the 'ADMIN Year Slicer'[Custom] column if there is no any filter applied on it. So you may need to check if there is only one available value in current filter context first, then use VALUES('ADMIN Year Slicer'[Custom]) = "2015" within the SWITCH function in your scenario. The formula below is for your reference. Smiley Happy

Measure Selection =
IF (
    HASONEVALUE ( 'ADMIN Year Slicer'[Custom] ),
    SWITCH (
        TRUE (),
        VALUES ( 'ADMIN Year Slicer'[Custom] ) = "2015", [2015 Turnover Rate],
        VALUES ( 'ADMIN Year Slicer'[Custom] ) = "2016", [2016 Turnover Rate],
        VALUES ( 'ADMIN Year Slicer'[Custom] ) = "2017", [YTD Turnover Rate],
        BLANK ()
    )
)

Or you can just use FIRSTNONBLANK function instead of VALUES function.

Measure Selection =
SWITCH (
    TRUE (),
    FIRSTNONBLANK ( 'ADMIN Year Slicer'[Custom], 1 ) = "2015", [2015 Turnover Rate],
    FIRSTNONBLANK ( 'ADMIN Year Slicer'[Custom], 1 ) = "2016", [2016 Turnover Rate],
    FIRSTNONBLANK ( 'ADMIN Year Slicer'[Custom], 1 ) = "2017", [YTD Turnover Rate],
    BLANK ()
)

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @pierre415,

 

The VALUES function will return all the values of the 'ADMIN Year Slicer'[Custom] column if there is no any filter applied on it. So you may need to check if there is only one available value in current filter context first, then use VALUES('ADMIN Year Slicer'[Custom]) = "2015" within the SWITCH function in your scenario. The formula below is for your reference. Smiley Happy

Measure Selection =
IF (
    HASONEVALUE ( 'ADMIN Year Slicer'[Custom] ),
    SWITCH (
        TRUE (),
        VALUES ( 'ADMIN Year Slicer'[Custom] ) = "2015", [2015 Turnover Rate],
        VALUES ( 'ADMIN Year Slicer'[Custom] ) = "2016", [2016 Turnover Rate],
        VALUES ( 'ADMIN Year Slicer'[Custom] ) = "2017", [YTD Turnover Rate],
        BLANK ()
    )
)

Or you can just use FIRSTNONBLANK function instead of VALUES function.

Measure Selection =
SWITCH (
    TRUE (),
    FIRSTNONBLANK ( 'ADMIN Year Slicer'[Custom], 1 ) = "2015", [2015 Turnover Rate],
    FIRSTNONBLANK ( 'ADMIN Year Slicer'[Custom], 1 ) = "2016", [2016 Turnover Rate],
    FIRSTNONBLANK ( 'ADMIN Year Slicer'[Custom], 1 ) = "2017", [YTD Turnover Rate],
    BLANK ()
)

 

Regards

It works thank you!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.