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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
newbie9
Helper I
Helper I

selectedvalue & switch

hi All,

 

I like to know the difference between 

switch( selectedvalue('table'[game])

.... some conditons....

)

 

vs

switch( 'table'[game]

.... some conditions...

)

 

what's the difference in using selectedvalue & not using selectedvalue?

 

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

 

In Power BI, the SELECTEDVALUE function and referencing a column directly can serve different purposes, and understanding when to use each depends on your specific requirements and the context of your calculations. Let's break down the differences between the two:

  1. Using SELECTEDVALUE:

    • SELECTEDVALUE is a DAX (Data Analysis Expressions) function in Power BI that is primarily used in measures or calculated columns.
    • It is typically used when you want to retrieve the single value selected in a slicer or filter context. For example, if you have a slicer for a game and want to perform calculations based on the selected game, you would use SELECTEDVALUE.
    • It's useful when you want to handle scenarios where there may be multiple selections and you want to ensure that only a single value is considered.
    • It helps avoid errors that might occur when there are multiple selections.

    Example:

Measure =
SWITCH(
SELECTEDVALUE('table'[game]),
"Game A", ...,
"Game B", ...,
"Game C", ...
)

 

Referencing the Column Directly:

  • When you reference a column directly like 'table'[game], you are not considering any filter or slicer context. You are working with the entire column of values in the 'game' column without regard to any selections or filters applied in your report.
  • This approach is useful when you want to aggregate or perform calculations on all the values in the column, regardless of the current selection. It's often used in calculated columns or in cases where you need to perform calculations on the entire dataset.

Example:

 

Measure =
SWITCH(
'table'[game],
"Game A", ...,
"Game B", ...,
"Game C", ...
)

 

In summary, the key difference is that SELECTEDVALUE is used to consider the current user-selected value in a slicer or filter context, while referencing the column directly ('table'[game]) ignores the context and works with all values in the column. The choice between the two depends on your specific calculation requirements and whether you need to consider user selections in your calculations.

View solution in original post

2 REPLIES 2
123abc
Community Champion
Community Champion

 

In Power BI, the SELECTEDVALUE function and referencing a column directly can serve different purposes, and understanding when to use each depends on your specific requirements and the context of your calculations. Let's break down the differences between the two:

  1. Using SELECTEDVALUE:

    • SELECTEDVALUE is a DAX (Data Analysis Expressions) function in Power BI that is primarily used in measures or calculated columns.
    • It is typically used when you want to retrieve the single value selected in a slicer or filter context. For example, if you have a slicer for a game and want to perform calculations based on the selected game, you would use SELECTEDVALUE.
    • It's useful when you want to handle scenarios where there may be multiple selections and you want to ensure that only a single value is considered.
    • It helps avoid errors that might occur when there are multiple selections.

    Example:

Measure =
SWITCH(
SELECTEDVALUE('table'[game]),
"Game A", ...,
"Game B", ...,
"Game C", ...
)

 

Referencing the Column Directly:

  • When you reference a column directly like 'table'[game], you are not considering any filter or slicer context. You are working with the entire column of values in the 'game' column without regard to any selections or filters applied in your report.
  • This approach is useful when you want to aggregate or perform calculations on all the values in the column, regardless of the current selection. It's often used in calculated columns or in cases where you need to perform calculations on the entire dataset.

Example:

 

Measure =
SWITCH(
'table'[game],
"Game A", ...,
"Game B", ...,
"Game C", ...
)

 

In summary, the key difference is that SELECTEDVALUE is used to consider the current user-selected value in a slicer or filter context, while referencing the column directly ('table'[game]) ignores the context and works with all values in the column. The choice between the two depends on your specific calculation requirements and whether you need to consider user selections in your calculations.

Thanks for the reply

it was helpful

can you help me with the below one too?

https://community.fabric.microsoft.com/t5/Desktop/count-of-columns/m-p/3679253

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.