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
Ondrej
Regular Visitor

Values based on condition from another table

hello

I am trying to solve a tricky problem

 

I have a survey with answers like "happy", "unhappy", etc. I need to assign a numeric value for rating - "happy = 1"

I know a can do conditional column. But there is a lot of words, and the numeric values might change. 

 

What I want to do is create a separate table with words in one column, assigned value in another, and then in the main table create a new column based on the rule set in this small separate table... 

 

HOW?

 

thank you

2 ACCEPTED SOLUTIONS
v-stephen-msft
Community Support
Community Support

Hi @Ondrej ,

 

You can create a separate table with words in one column and assigned value in another column. Then, you can use the Merge Queries feature to join the two tables based on the word column. After that, you can use the Replace Values feature to replace the words in the main table with their corresponding numeric values.

Merge queries overview - Power Query | Microsoft Learn

Replace values and errors - Power Query | Microsoft Learn

   

                                                                                                                                                         

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

Ondrej
Regular Visitor

it turns out the solution is pretty simple

you just do not want to do it in power query editor, but using simple DAX expression, you can add a column in power bi data view tab

 

NameOfNewColumn = LOOKUPVALUE('SourceTab'[WantedValue],'SourceTab'[ValueToCompare],'ThisTab'[ValueToCompare])

View solution in original post

2 REPLIES 2
Ondrej
Regular Visitor

it turns out the solution is pretty simple

you just do not want to do it in power query editor, but using simple DAX expression, you can add a column in power bi data view tab

 

NameOfNewColumn = LOOKUPVALUE('SourceTab'[WantedValue],'SourceTab'[ValueToCompare],'ThisTab'[ValueToCompare])
v-stephen-msft
Community Support
Community Support

Hi @Ondrej ,

 

You can create a separate table with words in one column and assigned value in another column. Then, you can use the Merge Queries feature to join the two tables based on the word column. After that, you can use the Replace Values feature to replace the words in the main table with their corresponding numeric values.

Merge queries overview - Power Query | Microsoft Learn

Replace values and errors - Power Query | Microsoft Learn

   

                                                                                                                                                         

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.           

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors