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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Saniat
Helper V
Helper V

Populate a column based on SELECTEDVALUE()

Hi,

Is it possible to populate a column based on user selection ?

I have a table '2'[userinput] with values "a" and "b".

I am giving the user the choice to select from these values.

I want to populate a column in my other table as:

NewValue = 

IF(SELECTEDVALUE('2'[userinput]) = "a", 1, 0)

This is the idea, but it looks like it's not working with this process.

Any suggestion on this ?

Thanks.
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Saniat ,

 

According to your description, measures are applicable, calculated columns are not.

Measures are calculated on demand based on the report selections, not the refreshed the data. So your measure in the column is calculated on demand, in the case of the column it is at data refresh. 

In other words, measures are dynamic, while calculated columns are static.

 

Therefore, you can use the SELECTEDVALUE() function to create a measure to return dynamic values.

Measure = 

IF(SELECTEDVALUE('2'[userinput]) = "a"10)
 
Calculated Columns and Measures in DAX - SQLBI

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @Saniat ,

 

Is your problem solved, please?

If it is solved, please mark the helpful reply as a solution, more people will benefit.

 

 

Best Regards,

Stephen Tao

v-stephen-msft
Community Support
Community Support

Hi @Saniat ,

 

According to your description, measures are applicable, calculated columns are not.

Measures are calculated on demand based on the report selections, not the refreshed the data. So your measure in the column is calculated on demand, in the case of the column it is at data refresh. 

In other words, measures are dynamic, while calculated columns are static.

 

Therefore, you can use the SELECTEDVALUE() function to create a measure to return dynamic values.

Measure = 

IF(SELECTEDVALUE('2'[userinput]) = "a"10)
 
Calculated Columns and Measures in DAX - SQLBI

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Saniat,

Check if field parameters can help

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...

 

Or old approach

How to create a Measure Slicer: https://youtu.be/b9352Vxuj-M

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.