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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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