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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply

Selectedvalue always return defalut value in switch

Hi ,

 

I have a slicer with 3 values Choice= 1,2,3 when i use selectedvalue - >

Value=SELECTEDVALUE('Table 1'[Choice],1) and call it in my switch function it's always return 1  even if 2 is selected
SWITCH([Value]
,1,Table 2[Ouvert N-1]
,2, Table 2[Ouvert N-2]
,3, Table 2[Ouvert N-3]
).
I try to create a column to see the value of the selectedvalue and it's correct but in th switch function is always 1.
Thank you for your help!
1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @Datavizuserpbi ,

 

As @PaulDBrown said, you can't return an entire column of values, you have to summarize those columns, for example to find their maximum value.

 

Measure = 
SWITCH (
    SELECTEDVALUE ( Slicer[Val] ),
    1, MAX ( 'Table 2'[Ouvert N-1] ),
    2, MAX ( 'Table 2'[Ouvert N-2] ),
    3, MAX ( 'Table 2'[Ouvert N-3] )
)

vkkfmsft_0-1657595554522.png


If you want to return different columns, you need to use field parameters.

 

vkkfmsft_1-1657595625215.png

vkkfmsft_2-1657595686986.png

vkkfmsft_3-1657595716237.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
v-kkf-msft
Community Support
Community Support

Hi @Datavizuserpbi ,

 

As @PaulDBrown said, you can't return an entire column of values, you have to summarize those columns, for example to find their maximum value.

 

Measure = 
SWITCH (
    SELECTEDVALUE ( Slicer[Val] ),
    1, MAX ( 'Table 2'[Ouvert N-1] ),
    2, MAX ( 'Table 2'[Ouvert N-2] ),
    3, MAX ( 'Table 2'[Ouvert N-3] )
)

vkkfmsft_0-1657595554522.png


If you want to return different columns, you need to use field parameters.

 

vkkfmsft_1-1657595625215.png

vkkfmsft_2-1657595686986.png

vkkfmsft_3-1657595716237.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

PaulDBrown
Community Champion
Community Champion

IF and SWICTH functions follow the order of the expressions: if the first expressions returns TRUE(), then that will be the result of the measure. If the first expression returns FALSE, then the second row is checked etc....

What are you trying to achieve? If you need to list the selections you can try:

 

List selection = 
CONCATENATEX(VALUES(Slicer Table[Field]), Slicer Table [Field], ", ")

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






The problem is the value of the expression it should return either 1,2 or 3 but it doesn't return 2 or 3 even they are selected with the slicer. The value by default is 1 - > Value=SELECTEDVALUE('Table 1'[Choice],1) .

The expression is always equal to the default value even if it's not selected

Sorry, I'm not sure I'm following.  It works in this example:

Slicer Value = 
SWITCH(
    SELECTEDVALUE(Slicer[Val]),
1, "AAAA",
2, "BBB",
3, "CCC",
4, "D",
"Z")

 

slicer.gif

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Sorry let me explain with your example, slicer value is a column and based on the slicer the column slicer value is gonna be equal to:

     column 1 if 1 is selected ,

     column 2 if 2 is selected ,

     column 3 if 3 is selected , Blank()

Slicer Value = 
SWITCH(
    SELECTEDVALUE(Slicer[Val]),
1, column 1,
2, column 2,
3, column 3,
Blank())

The problem is  the selectedvalue is always blank even if 1,2,or 3 is selected so the switch doesn't work 

Val=GENERATESERIES(1, 3, 1)

Thank you for your help!

The problem is that SWITCH returns a scalar value; it cannot return a whole column, which is what your SWITCH statement returns





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors